Databases: Getting values by column name

Ben Last ben at benlast.com
Wed Aug 18 02:41:45 EDT 2004


> From: python-list-bounces+ben=benlast.com at python.org
> [mailto:python-list-bounces+ben=benlast.com at python.org]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).

b


______________________________________________________________________
This email has been scanned by the MessageLabs Email Security System.
For more information please visit http://www.messagelabs.com/email 
______________________________________________________________________



More information about the Python-list mailing list