[DB-SIG] DB API 2.0 - dictionary fetch ?

Greg Stein gstein@lyra.org
Fri, 23 Jun 2000 18:53:25 -0700


On Fri, Jun 23, 2000 at 07:05:46PM -0400, jonan-lists-python-db@callisia.com wrote:
> Hello,
> 
>     I am wondering if the 2.0 db api provides a method for returning
>     a dictionary of results instead of a list ? Something like
>     perl-DBI's fetch_hashref . 
>     
>     I am using the latest MySQLdb and it mentions a fetchalldict method
>     in the tutor examples, though the method is non-existant when put
>     to use. The source MySQLdb.py has comment of fetchXXX depracated
>     just above the fetchalldict, so is it gone ?
> 
>     The very sparse documentation and db api spec also mention different
>     cursor classes which maybe is the way to do it ? Im using
>     my own function to make the dictionary but it would be nice
>     if it was in the API.

Fetching a dictionary is not part of the API because it is so easy to put
that into the Python code. Making it part of the API would just increase the
burden for people to build a DBAPI interface.

[ although, current implementation style has used a small C code base plus a
  higher-level Python interface; presuming that really becomes "typical"
  then we could mandate the dict interface since most DBAPI modules could
  just do that in their Python portion... ]

In any case... it isn't a standard part of the DBAPI interface.

There was a call for tools a while back that was pretty much a non-starter.
But whatever the case, I posted a module that has been around since 1996 to
provide a dict-like interface. See the info at:

  http://www.python.org/pipermail/db-sig/2000-April/002329.html


Cheers,
-g

-- 
Greg Stein, http://www.lyra.org/