Retrieving column values by column name with MySQLdb

jorma kala jjkk73 at
Fri Jun 19 10:46:46 EDT 2009

Is there a way of retrieving the value of columns in the rows returned by
fetchall, by column name instead of index on the row?
Code Snippet:

     query="select * from employees"
     cursor = db.cursor ()
     cursor.execute (query)
     rows = cursor.fetchall ()

      for row in rows:
               print row[0]

Instead of specifying the index of the row to retrieve the first column
(row[0]), I'd like to retrieve the value of the first column by column name.
Something like row.get('employee_id')
Is something of the sort possible with Mysqdb?
Thanks very much.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the Python-list mailing list