Convert string to command..

Hrvoje Niksic hniksic at xemacs.org
Fri Oct 19 09:15:33 CEST 2007


Abandoned <besturk at gmail.com> writes:

>> Use a different column type for cache2's column, one more appropriate
>> for storing binary characters (perhaps BYTEA for Postgres).  Don't
>> forget to also use a bind variable, something like:
>>
>> cursor.execute("INSERT INTO cache2 VALUES (?)", a)
>>
>> Using "INSERT ... ('%s')" % (a) won't work, since the huge binary
>> string in a can contain arbitrary characters, including the single
>> quote.
>
> I tryed:
> cursor.execute("INSERT INTO cache2 VALUES (?)", a)

Why are you ignoring the first sentence: "Use a different column type
for cache2's column, ..."?  The use of bind variables in INSERT will
work only *after* you do the rest of the work.



More information about the Python-list mailing list