Databases: Getting values by column name

Ben Last ben at
Wed Aug 18 08:41:45 CEST 2004

> From: at
> [ at]On Behalf Of
> Anthony_Barker
> what about db_rows?
An excellent suggestion, as were the points about MySQLdb's DictCursors; I
thought it appropriate to try and show that the database API in *general*
does include what's needed (i.e., the cursor.description attribute).  I
suspect this particular wheel has been reinvented many times :)
Something I noted, but forgot to mention (and which is worth mentioning for
anyone who googles their way into this thread in the future) is that
non-column selects (such as SELECT COUNT(*) or SHOW TABLES or DESCRIBE)
return descriptions whose field names may or may not be what you expect (for
example, a SHOW TABLES returns a field name "Tables_in_x" where x is the
name of the database).


This email has been scanned by the MessageLabs Email Security System.
For more information please visit 

More information about the Python-list mailing list