Database bind variables?

Andrew Fabbro andrew-wants-no-spam at fabbro.org
Sat Nov 22 07:35:21 CET 2003


Python + Postgres.  Finding good documentation on working with
databases in python is proving more challenging than writing the code
;)

In perl, I often do things like this:

$sql = $dbh->prepare ("
  UPDATE accounts
  SET note = ?
  WHERE account_number = ?");

and then later come back with

$note = "It's raining, it's pouring";
$sql = $dbh->execute($note, 123);

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...;)

Quoting is not a pleasant solution.  Neither is the % interpolation -
it would fail in the above case because the apostrophe in $note would
confuse it.

Help!?

-Drew




More information about the Python-list mailing list