Convert string to command..

Abandoned besturk at gmail.com
Fri Oct 19 07:25:05 CEST 2007


On Oct 18, 8:53 pm, Hrvoje Niksic <hnik... at xemacs.org> wrote:
> Abandoned <best... 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.

I tryed:
cursor.execute("INSERT INTO cache2 VALUES (?)", a)
and
cursor.execute("INSERT INTO cache2 VALUES (%s)", (a,) )
but the result is same..

> 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".




More information about the Python-list mailing list