title: Sqlalchemy get integer from text query
body: <p>I am fighting with some legacy code and the correct way to get an integer value from the database. I am trying to get it like this: </p>
  
  <pre><code>db = make_session() # this returns a session
  q = db.query('count').from_statement(text("""
      SELECT count(1) as count FROM mytable
      WHERE somevar=:somevar;
  """)).params(somevar=1)
  return [p[0] for p in q]
  </code></pre>
  
  <p>This returns <code>[81L]</code>. I would also think that the value is <code>q[0]</code> but that raises and Exception. What is the correct way to use Sqlalchemy in this case and get only an integer here.</p>