[DB-SIG] inserting strings into postgres db using pgdb (escaping
b.n.lawrence at rl.ac.uk
Wed Jun 18 14:25:15 EDT 2003
I'm just playing at a common db core module for an application. It works ok
with gadfly and mysql, and I'm trying to extend it to postgresql.
I'm using the pgdb module ...
At the moment (mysql) I do inserts with something like
cmd="insert into table blah (x,y) values (%s%s)"
(replacing the %s with ? for gadfly).
This breaks with postgres ...
I tried something like
cmd='insert into table blah (x,y) values (string.join(
map(lambda x: repr(x),data),','))
but that breaks with
ERROR: Attribute ... not found
Clearly I can muck around parsing strings and escaping things, but
that seems remarkably clumsy, and I can't believe I'm the only person with
this problem. I've had a google and rummaged in the manuals, but obviously
didn't turn over the right leaf ... how does one do this with postgres?
I'm not on the mailing list, so if you can help, could you please reply
directly? It's not an easy thing to search for in the archive, so apologies
if this is a much rehearsed problem.
More information about the DB-SIG