Pygresql classic vs DB-API interface

Steve Bergman steve at rueb.com
Mon Sep 19 10:06:52 EDT 2005


I am relatively new to python and am developing an application using 
mod_python/pygresql/postgresql.

Being attracted to the idea of database portability, I started out using 
the DB-API 2.0 compliant pgdb module.  However, I am finding it to be 
pretty clunky compared to the classic pg interface.
It just doesn't seem "pythonic" to me.  Chief among my concerns is the 
way it won't return results as a dictionary, so I have to address the 
data using cryptic numeric indeces.  To be fair, the 3rd party dtuple 
module lets me use dictionaries, but it still seems a bit clunky.  Also, 
insertion into a table seems unnecessarily ugly.  With the classic 
interface, I just pass a tablename and a dictionary and let the 
interface deal with it.  With pgdb, if I want to do something like that 
I've got to write my own code to do it.  Or does DB-API and pyformat 
allow me to do this in a more elegant way of which I am unaware?

I still like the portability of pgdb though.  So, does anyone have any 
recommendations?  Perhaps a module that does for inserts and updates 
kind of what dtuple does for selects?

Thank you for any guidance.

Steve Bergman



More information about the Python-list mailing list