Strings and % sign fails - Help Please

Fredrik Lundh fredrik at
Fri Mar 24 23:16:26 CET 2006

Siah wrote:

> Problem Solved.  The problem was with psycopg.Binary whose mere job is
> to convert bytes into clear text for sql statement.

no, its job is to wrap strings that contain binary blobs, so that data binding
works properly.  you're supposed to do

    cursor.execute(statement, Binary(data))

and not



    cursor.execute("some statement %s" % Binary(statement))

or some other sillyness.  it's an object wrapper, not an escape function for
arbitrary SQL.  Python's not PHP.

for more details, see "Type Objects and Constructors" on this page


More information about the Python-list mailing list