Mailing List Archive

psycopg insert into unicode problem
Hi,

I've installed zope2.7 and zope-psycopgda on Debian Sarge. (The official deb packages.) According to the ZopeBook 2.6 Relational Database Connectivity chapter a Psycopg_database_connection and 2 Z SQL methods were added to a test folder. The select query works without any problems, and The insert into works fine till I try to insert a string containing a character encoding over 127. I get the following error message:

Error, psycopg.ProgrammingError: ERROR: invalid byte sequence for encoding "UNICODE": 0xe16a6f insert into nevek (azon, nev) values( 13, 'Lájos');

In Z SQL method I wrote the following:

insert into nevek (azon, nev) values(
<dtml-sqlvar azon type="int">,
<dtml-sqlvar nev type="string">);

(azon=id, nev=name)
The postgres database is unicode encoded. What shall I do in order to insert these texts into database via zope? (with psql I can insert it smoothly.)

Thanx,

Peter
____________________________________________________________________
Miert fizetsz az internetert? Korlatlan, ingyenes internet hozzaferes a FreeStarttol.
Probald ki most! http://www.freestart.hu
Re: psycopg insert into unicode problem [ In reply to ]
Il giorno mer, 02/11/2005 alle 12.07 +0100, abraham.peter@freestart.hu
ha scritto:
[snip]
> (azon=id, nev=name)
> The postgres database is unicode encoded. What shall I do in order to
> insert these texts into database via zope? (with psql I can insert it
> smoothly.)

Pass a utf-8 encoded string or use a version of psycopg that supports
unicode strings and pass a unicode object.

--
Federico Di Gregorio http://people.initd.org/fog
Debian GNU/Linux Developer fog@debian.org
INIT.D Developer fog@initd.org
Spesso crescere ed andare a vivere da soli è l'unico modo di restare
bambini. -- Alice Fontana