Database bind variables?

David M. Cook davecook at nowhere.net
Sat Nov 22 03:57:48 EST 2003


In article <ba6a8303.0311212235.18c95df6 at posting.google.com>, Andrew Fabbro
wrote:

> I haven't found a way to do this yet with pygresql (or should I be
> using something else?  if only the docs where there...;)

All the postgresql adaptors I'm aware of use "pyformat" interpolation, which
is similar to python's dictionary string interpolation, e.g.

cursor.execute("select * from baz where foo=%(foo)s", {'foo' : 1234})

This does any necessary quoting for you.

Dave Cook




More information about the Python-list mailing list