title: SqlAlchemy query in a template page
body: <p>I have a query like this:</p>
  
  <pre><code>session.query(System).filter_by(id_system = s.id_system).join(Command).filter_by(id_command=c.id_command).first()
  </code></pre>
  
  <p>I'd like to do this query in a template page (I'm using mako), but it doesn't work:</p>
  
  <pre><code>% for c in s.commands:
      code = session.query(System).filter....
  % endfor
  </code></pre>
  
  <p>What is best way to do a query in pages? Or is it not possible?</p>