[DB-SIG] First suggestion for db-api 3.0

Vernon Cole vernondcole at gmail.com
Mon Sep 22 16:25:38 CEST 2008


Dear Pythonaholics:

I have not been following the development of Python 2.6 and 3.0, so the
following took me by surprise when I read it this morning. It seems to me on
first glance, that this new feature, "Named Tuple", is exactly what is
needed to make fields in database records (or columns in database rows if
you prefer) more accessible to a python programmer.

From: Discussion of IronPython <users at lists.ironpython.com>...

On Fri, Sep 19, 2008 at 6:26 AM, Michael Foord <fuzzyman at voidspace.org.uk>wrote:
Hello all,

At PyCon UK Raymond Hettinger showed off the Named Tuple; a very useful
recipe for creating tuples with named fields. It is becoming part of the
standard library in Python 2.6.

http://code.activestate.com/recipes/500261/

>>> from namedtuple import namedtuple
>>> thing = namedtuple('thing', ('whizz', 'pop'))
>>> thing
<class '__builtin__.thing'>
>>> i = thing(1, 2)
>>> i.whizz
1
>>> i.pop
2
>>> w, p = i
>>> w, p
(1, 2)
>>> i
thing(whizz=1, pop=2)
>>>

I would like to suggest that we start the process of creating a dbapi 3.0
specification, and that the new spec define the returned data as an iterator
of Named Tuples.
--
Vernon Cole
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/db-sig/attachments/20080922/7f42c06f/attachment.htm>


More information about the DB-SIG mailing list