Re: Convert string to command..
On Oct 18, 8:53 pm, Hrvoje Niksic <hnik...@xemacs .orgwrote:
I tryed:
cursor.execute( "INSERT INTO cache2 VALUES (?)", a)
and
cursor.execute( "INSERT INTO cache2 VALUES (%s)", (a,) )
but the result is same..
On Oct 18, 8:53 pm, Hrvoje Niksic <hnik...@xemacs .orgwrote:
Abandoned <best...@gmail. comwrites:
>
>
Good! :-)
>
>
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.
When you load it, convert the string to dict with cPickle.loads
instead of with eval.
instead of with eval.
Yes i understand and this very very good ;)
Good! :-)
>
psycopg2.Progra mmingError: invalid byte sequence for encoding "UTF8":
0x80
HINT: This error can also happen if the byte sequence does not match
the encoding expected by the server, which is controlled by
"client_encodin g".
0x80
HINT: This error can also happen if the byte sequence does not match
the encoding expected by the server, which is controlled by
"client_encodin g".
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.
cursor.execute( "INSERT INTO cache2 VALUES (?)", a)
and
cursor.execute( "INSERT INTO cache2 VALUES (%s)", (a,) )
but the result is same..
psycopg2.Progra mmingError: invalid byte sequence for encoding "UTF8":
0x80
HINT: This error can also happen if the byte sequence does not match
the encoding expected by the server, which is controlled by
"client_encodin g".
0x80
HINT: This error can also happen if the byte sequence does not match
the encoding expected by the server, which is controlled by
"client_encodin g".
Comment