On Mon, 26 Mar 2012 15:54:52 +0200, Thomas Rachel
<nutznetz-0c1b6768-bfa9-48d5-a470->
declaimed the following in gmane.comp.python.general:
> Am 26.03.2012 00:59 schrieb Dennis Lee Bieber:
>
> > If you use the longer form
> >
> > con = db.connect()
> > cur = con.cursor()
> >
> > the cursor object, in all that I've worked with, does function for
> > iteration
>
> I use this form regularly with MySQLdb and am now surprised to see that
> this is optional according to http://www.python.org/dev/peps/pep-0249/.
>
> So a database cursor is not required to be iterable, alas.
>
Sounds like it may be time to do a survey...
MySQLdb iterable cursor
Cursor, DictCursor, SSCursor, SSDictCursor (the
first two suck the entire result set to the client and then feed it to
the application, the latter two keep the results on the server and fetch
them as needed; the Dict versions obviously return dictionaries, the
others return tuples)
SQLite3 iterable cursor
Dictionary-like cursor using a row-factory (in
Python 2.5 documentation: 13.13.6.2 Accessing columns by name instead of
by index )
Psycopg iterable cursor
dictionary-like cursor
http://initd.org/psycopg/docs/extras...sor-subclasses
Pygresql iterable cursor
dictresult() ?
py-postgresql unknown -- the only documentation I found appears to
be for the NON-DB-API interface
Row object supports index or key access
pypgsql NOT iterable (based on readme and source)
Result object supports index or key access
Can anyone add to this? mxODBC, pyodbc, M$ SQL server?
One thing I note in the above is that ALL of those adapters have
built-in means of accessing return data as a dictionary, so the OP's
generator function to create dictionary values is likely superfluous,
and may even be a bottleneck in processing.
--
Wulfraed Dennis Lee Bieber AF6VN
HTTP://wlfraed.home.netcom.com/