title: AttributeError: 'long' object has no attribute 'fetchall'
body: <p>I'm attempting to execute some sql using the mysql-flask python extension. The below code always returns a long for some reason.</p>
  
  <pre><code>stringify = lambda x : '"' + x + '"'
  if request.method == 'POST':
          sql = "select * from users where username = " + stringify(request.form['username'])
          user = g.db.cursor().execute(sql).fetchall()
  </code></pre>
  
  <p>Error:</p>
  
  <pre><code> user = g.db.cursor().execute(sql).fetchall()
  AttributeError: 'long' object has no attribute 'fetchall'
  </code></pre>
  
  <p>Why doesn't this return a result set? </p>
  
  <p>Also, I can execute insert statements just fine.</p>
  
  <p>FIX (ANSWER): </p>
  
  <pre><code>def get_data(g, sql):
      cursor = g.db.cursor()
      cursor.execute(sql)
      data = [dict((cursor.description[idx][0], value) for idx, value in enumerate(row)) for row in cursor.fetchall()]
      return data
  </code></pre>