Databases: Getting values by column name

Ian Sparks Ian.Sparks at etrials.com
Tue Aug 17 10:11:56 EDT 2004


Robert Ferber Wrote...
> Is there a way to use them as dictionaries, ie with 
> Index-Strings (=column
> names) as indexes?

I've had some success with Dtuple :

http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/81252

Some database adapters supply a dictionary interface as an extension to the DBAPI 2.0 (the MySQL adapter comes to mind as an example).

> -----Original Message-----
> From: Robert Ferber [mailto:rob at nospam.net]
> Sent: Tuesday, August 17, 2004 9:53 AM
> To: python-list at python.org
> Subject: Databases: Getting values by column name
> 
> 
> Hi,
> 
> I can't find any good documentation about the Python-database 
> module, all I
> found was this rudimentary (no examples, no references) piece here:
> 
> http://www.python.org/peps/pep-0249.html
> 
> Anyway, this and also this tutorial here:
> 
> http://www.devshed.com/c/a/Python/MySQL-Connectivity-With-Python/2/
> 
> only use database rows as sequences, ie as arrays with 
> numerical index.
> This gives you loads of problems when using "select *" and 
> also bad code
> readability when selecting specific columns.
> 
> Is there a way to use them as dictionaries, ie with 
> Index-Strings (=column
> names) as indexes?
> 
> BTW, is there any good searchable reference to Python's 
> functions, with
> examples and cross-references to similar functions?
> 
> Thanks a lot,
> 
> Robert
> -- 
> http://mail.python.org/mailman/listinfo/python-list
> 



More information about the Python-list mailing list