Convert string to command..
Hrvoje Niksic
hniksic at xemacs.org
Thu Oct 18 13:53:31 EDT 2007
Abandoned <besturk at gmail.com> writes:
> > When you load it, convert the string to dict with cPickle.loads
> > instead of with eval.
>
> Yes i understand and this very very good ;)
Good! :-)
> psycopg2.ProgrammingError: 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_encoding".
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.
More information about the Python-list
mailing list