psycopg2 or pygresql?

exhuma.twn exhuma at gmail.com
Wed Sep 19 17:06:25 CEST 2007


Plain and simple. What would you use?

So far I have written everything with psycopg2. One thing that annoys
me is that I cannot easily access the column names from a query. I
know that this is not part of the DBAPI2  so I cannot expect the model
to suport it.

I quite like the "mogrify" method of psycopg2 very much. It's very
useful for debugging.

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.

The reason: I wrote a very simple Qt-Widget (inherited from
QTableWidget) that takes a SQL query and displays the results. And I
would like to have the columns ordered the same way as I specified in
the query *with* a header-label. For now I hava a method on the widget
which takes a query, *and* a list of labels.

I can live with that though. Although it itches me.

Would pygresql solve my dilemma? Or would you rather say: "Don't use
pygresql!"  ;)




More information about the Python-list mailing list