title: Raw SQL within Pylons app that uses SQLAlchemy?
body: <p>I've inherited a Pylons app that uses SQLAlchemy. I know nothing about SQLAlchemy and very little about Pylons :)</p>
  
  <p>I need to run some raw SQL from within the app. The SQLAlchemy currently seems to be working in the following way (example code):</p>
  
  <pre><code>import myapp.model as model
  model.Session.query(model.KeyValue) # existing code
              .join(model.Key)
              .filter(model.Key.name == name)
              ).count() == 0, name
  </code></pre>
  
  <p>How do I get it to run raw SQL? I see that I need an execute() statement, but how exactly do I run it? The following both fail:</p>
  
  <pre><code>model.Session.execute('create table hello_world;')
  model.Connection.execute("""
  create table hello_world;
  """)
  </code></pre>
  
  <p>What's the magic invocation? There's no reference to a Connection object in the existing code, and I'm not sure how to create one. </p>