[PYTHON DB-SIG] DB-Modules returning lists of dicts

David Walton david@alphagene.com
Thu, 09 Jan 1997 08:14:22 -0500

Hey folks,

May I assume that due to the lack of response (with the exception
of Glenn Colby's, thanks for your comments Glenn), that there is
no interest out there in Python database modules giving the *option*
to return a list of dictionaries as an alternative to the list
of tuples that are currently returned?

Glenn, comments that at the Jackson Laboratory, while they are
still having their Sybase module return lists of dictionaries, they
are doing a rewrite that will cause it to return a list of tuples
instead (like the API).  Glenn also comments that he is setting up
a SQL class that abstracts away the programmers knowledge of
the schema, and that he can't see any use for returning a list
of dictionaries due to the cost in the over-head of the datastructure.
(part of what I just said may have come from mail that Glenn and
I exchanged after his initial message.  Glenn, please correct me
if I misinterpreted your words.)

This is fine for their needs.  In our case however, we have no desire 
to abstract away the relational schema from our developers.  We also
find it very useful to be able to reference the results of a query
by column name, instead of column number.  It makes it possible for
any code that is using a 'SELECT * FROM foo' to continue to function
when a column is inserted to the schema for foo.  And let me say, 
at this point in time this happens frequently to us, because our
schema is still a moving target.

I realize that it is possible to take the "description" provided
by the API and associate the column names with the columns in my
list of tuples.  I do that now.  I just thought it would be
a little more efficient to have the module returning the rows to me
as dictionaries in the first place.

I'm very interested in knowing why folks find this option undesirable.
(if they actually do)

Glenn's reason being "there is so much space overhead when returning 
a dictionary for each row in the database.".  However, for us this
is not a concern (at least right now), and we would find the
option useful.

Thanks again for any input folks can contribute.


Dave Walton
Scientific Software Engineer
AlphaGene, Inc.

DB-SIG  - SIG on Tabular Databases in Python

send messages to: db-sig@python.org
administrivia to: db-sig-request@python.org