PDO and database abstraction

Luiz Geron luizgeron at gmail.com
Tue Oct 25 09:15:17 EDT 2005


This is one example where I need to use such abstraction:
I have a dictionary with the fields and values to be inserted into the
database, with a code like this:

dic = {'field1' : 1, 'field2' : 2} #this dict comes from a Cherrypy
request
cur.execute('update table set field_one = :value1, field2 = :value2' ,
dic)

and I want to use it even with kinterbasdb, wich does not support named
paramstyle. The problem with your use of % is that the db module does
not automatically put '' in varchar fields, and so on. This is what PDO
does, or say that does. I think that I should make a wrapper that
simply swap :var to ? when the db paramstyle is qmark, and so on. Is
this correct?




More information about the Python-list mailing list