[DB-SIG] May we get an actual ANSWER to the F.A.Q...How can I construct a dictionary???

Lloyd Kvam lkvam at venix.com
Mon Sep 22 19:06:50 EDT 2003


MySQLdb in the cursor.py module includes:
class CursorDictRowsMixIn:
     """This is a MixIn class that causes all rows to be returned as
     dictionaries. This is a non-standard feature."""
     _fetch_type = 1

The documentation explains how to make this mixin the default.  I
have always just created a dictionary when I needed it.  For reporting
and general searching by eye, I have found it is easier and quicker to
deal with lists of tuple values rather than lists of dictionaries.

Vernon Cole wrote:

> I have been away from the leading edge for a long time, and am trying to
> jump back
> in and learn the new stuff. Python seems like a GREAT tool.
> But.....
> 
> From:
> 	...PEP: 	249	
> 	...Title: 	Python Database API Specification v2.0	
> 	...Version: 	$Revision: 1.9 $	
> I extract the following:	
> vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv
>     Question: 
> 
>        How can I construct a dictionary out of the tuples returned by
>        .fetchxxx():
> 
>     Answer:
> 
>        There are several existing tools available which provide
>        helpers for this task. Most of them use the approach of using
>        the column names defined in the cursor attribute .description
>        as basis for the keys in the row dictionary.
> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Nice to hear that there are "several existing tools".
> 
> I have been searching for a week now, but cannot find any of them.
> 
> Would someone be so kind as to actually publish a LIST of such tools??
> 
> 	I find it difficult to believe that the "latest and greatest" tools
> available
> in the 21st century still cannot return a value from a named field (column)
> in one row of a  database. Good grief! How can I NOT have a feature on a 256
> MB Pentium in 2003 that I had
> on a 30 KB PDP-11 in 1983?
> 	Was RDM _that_ far ahead of its time?
> --------------
> Vernon Cole
> once (a long time ago) a developer of RDM.
> wnvcole AT nospam.peppermillcas.com
> 
> 
> 
> 
> _______________________________________________
> DB-SIG maillist  -  DB-SIG at python.org
> http://mail.python.org/mailman/listinfo/db-sig
> 

-- 
Lloyd Kvam
Venix Corp.
1 Court Street, Suite 378
Lebanon, NH 03766-1358

voice:	603-443-6155
fax:	801-459-9582




More information about the DB-SIG mailing list