DB API/psycogpg Quibbles

I’ve been learning about talking to databases through Python, which means learning the DB API v2.0. At the moment I’m using the Psycopg adapter, mostly because the ODBC driver is completely broken.

One of the most helpful things an adapter can do is quote values being passed into queries. Unfortunately table name and column name quoting is different to value quoting, but every argument to a query is value quoted, which breaks things. I could do the table quoting myself and leave the value quoting to the adapter, but that would make each query a little too icky for my liking, so I’m doing all the quoting myself. There’s probably going to be a way to do this properly in the next version of psycopg.

A feature I’m a little surprised isn’t around is a simple way of getting an auto id column value from the cursor object, instead I have to do yet another query.


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: