[DB-SIG] Use of record sets

John Shafaee pshafaee@hostway.com
Tue, 03 Apr 2001 21:57:38 -0500


--------------68D287B8B3DAD1597F2E9030
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit

Hello!

My name is John Shafaee and I am a Python developer (sorry for opening
with the traditional AA like greeting). I am very excited to see  the
continuing development of the Python DB API.

My friends and I have been working with several Python modules for
connecting to MySQL, PostgreSQL, and Interbase RDBMSs in the past two
years. To help generalize DB access code, we decided to put together a
DBFactory module for creating connections to multiple DBs. The module is
at a higher-level than the Python DB API specifications, but there are
some overlaps.

I noticed that the DB API interface is still using sequences for working
with query results. Although this is sufficient, sequences are indexed
by integers and are therefore difficult to program with. For example, as
shown in the following code, using sequence indexes make the code less
readable and more error prone.

curs.execute( "SELECT id, first_name, last_name FROM some_table WHERE id
> 10" )

result = curs.fetchone()

print "Found id '%s', first name '%s' and last name '%s'"%( result[0],
result[1], result[2] )

The DBFactory module returns query results as a sequence of Records.
Records are Python UserDict objects that index field data by the
field(column) name. This is very convenient when interpolating results
in a string. The above example code would look like the following if
written in terms of lists of Records:

print "Found id '%s', first name '%s' and last name
'%s'"%( result['id'], result['first_name'], result['last_name'] )

I was wondering if this is something that you have considered. If not, I
was wondering what were the proper channels that I would need to go
through to make this suggestion open to the rest of the Python
DB API community.

Looking forward to your response.

Best,
John Shafaee

--------------68D287B8B3DAD1597F2E9030
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
Hello!
<p>My name is John Shafaee and I&nbsp;am a Python developer (sorry for
opening with the traditional AA like greeting). I&nbsp;am very excited
to see&nbsp; the continuing development of the Python DB&nbsp;API.
<p>My friends and I have been working with several Python modules for connecting
to MySQL, PostgreSQL, and Interbase RDBMSs in the past two years. To help
generalize DB&nbsp;access code, we decided to put together a DBFactory
module for creating connections to multiple DBs. The module is at a higher-level
than the Python DB&nbsp;API specifications, but there are some overlaps.
<p>I noticed that the DB&nbsp;API&nbsp;interface is still using sequences
for working with query results. Although this is sufficient, sequences
are indexed by integers and are therefore difficult to program with. For
example, as shown in the following code, using sequence indexes make the
code less readable and more error prone.<tt></tt>
<p><tt>curs.execute(&nbsp;"SELECT id, first_name, last_name FROM&nbsp;some_table
WHERE id > 10" )</tt><tt></tt>
<p><tt>result = curs.fetchone()</tt><tt></tt>
<p><tt>print "Found id '%s', first name '%s' and last name '%s'"%(&nbsp;result[0],
result[1], result[2] )</tt>
<p>The DBFactory module returns query results as a sequence of Records.
Records are Python UserDict objects that index field data by the field(column)
name. This is very convenient when interpolating results in a string. The
above example code would look like the following if written in terms of
lists of Records:
<p><tt>print "Found id '%s', first name '%s' and last name '%s'"%(&nbsp;result['id'],
result['first_name'], result['last_name'] )</tt>
<p>I was wondering if this is something that you have considered. If not,
I was wondering what were the proper channels that I would need to go through
to make this suggestion open to the rest of the Python DB&nbsp;API&nbsp;community.
<p>Looking forward to your response.
<p>Best,
<br>John Shafaee</html>

--------------68D287B8B3DAD1597F2E9030--