psycopg2 or pygresql?

jay graves jaywgraves at gmail.com
Wed Sep 19 11:39:42 EDT 2007


On Sep 19, 10:06 am, "exhuma.twn" <exh... at gmail.com> wrote:
> And before someone says: "Use the DictCursor-factory to access column
> names". Yes I can do that. But a dict does not guarantee the same
> order of keys as the columns were specified in the query.

But you can iterate over the cursor.description sequence and then look
up the column value (by name or index).  I haven't specifically tried
this with your setup but I have used it with various DBAPI2 compliant
modules.  (SQLite, pyodbc, win32 odbc, etc)  There are lots of goodies
in the cursor.description but each implementation varies on what it
provides.  Check out the PEP for more info.

http://www.python.org/dev/peps/pep-0249/

HTH.
Jay




More information about the Python-list mailing list