Retrieving column values by column name with MySQLdb

Mike Kazantsev mk.fraggod at
Fri Jun 19 11:07:11 EDT 2009

On Fri, 19 Jun 2009 15:46:46 +0100
jorma kala <jjkk73 at> wrote:

> 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?

Try this:

  db = MySQLdb.Connection(host=host,user=user,passwd=passwd,db=database)
  result = db.store_result()
  data = result.fetch_row(maxrows=0, how=1)

Mike Kazantsev //
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 205 bytes
Desc: not available
URL: <>

More information about the Python-list mailing list