[DB-SIG] fetchone -> dictionary?

Bill Tutt billtut@microsoft.com
Wed, 20 Jan 1999 16:48:52 -0800


From: Greg Stein [mailto:gstein@lyra.org]
> 
> 
> Suggestions like these have come up in the past. The reason that a
> simple tuple is returned is that it is much easier for the module
> implementor. Rather than requiring all module implementors to 
> deal with
> more complex data structures, we rely on Python itself to do the work.
> You can write a simple layer over the cursor object that fills in a
> dictionary based on the cursor.description results plus the returned
> tuple. If you check the archives, you'll find a solution that I posted
> called "dtuple.py" that can wrap a tuple into a lightweight object
> allowing "row.FieldName" types of access. It may also allow the
> dict-type access that you describe, but I've forgotton.
> 

dtuple.py indeed does allow a read-only dict-type access to the data.
If you can't dig it up in the archives, I know I have a copy here someplace.
I think I may have posted a cursor wrapper object that used dtuple as well,
but can't recall for sure.

Bill