Encoding problems with cursor.execute

Ernesto Revilla <[email protected]> Thu, 11 Aug 2005 00:33:31 +0200
Newsgroups gmane.comp.db.rekall.devel
Message-ID <[email protected]>
--===============1211024838==
Content-Type: multipart/alternative; 
	boundary="----=_Part_2237_11802196.1123713211978"

------=_Part_2237_11802196.1123713211978
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hello.

When I query the database with the .execute method, and results have=20
international chars, I receive results with wrong international chars. (at=
=20
least I don't know the encoding.) Result are strings, not unicodes.

Could anyone give me some hints?
Here everything runs with UTF-8 (postgresql, shell, rekall, etc.) My code=
=20
is:
def eventFunc(ctrl, qrow, value):
# read default address
flds=3D("domicilio","poblacion","codigopostal","provincia")
blk=3Dctrl.__parent__.direccion
sql=3Du"select %s from personasdirecciones where personaid=3D%s AND orden=
=3D1"
cur=3Dctrl.cursor()
cur.execute(sql % (",".join(flds), value),[])
if cur.rowcount>0:
res=3Dcur.fetchone()
for i,fld in enumerate(flds):
print cur.description()[i],"(",type(res[i]),"):",res[i]
getattr(blk,fld).value=3Dres[i]


Best regards,
Erny
Spain

------=_Part_2237_11802196.1123713211978
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
Content-Disposition: inline

Hello.<br>
<br>
When I query the database with the .execute method, and results have
international chars, I receive results with wrong international chars.
(at least I don't know the encoding.) Result are strings, not unicodes.<br>
<br>
Could anyone give me some hints?<br>
Here everything runs with UTF-8 (postgresql, shell, rekall, etc.) My code i=
s:<br>
def eventFunc(ctrl, qrow, value):<br>
&nbsp;&nbsp;&nbsp; # read default address<br>
&nbsp;&nbsp;&nbsp; flds=3D(&quot;domicilio&quot;,&quot;poblacion&quot;,&quo=
t;codigopostal&quot;,&quot;provincia&quot;)<br>
&nbsp;&nbsp;&nbsp; blk=3Dctrl.__parent__.direccion<br>
&nbsp;&nbsp;&nbsp; sql=3Du&quot;select %s from personasdirecciones where pe=
rsonaid=3D%s AND orden=3D1&quot;<br>
&nbsp;&nbsp;&nbsp; cur=3Dctrl.cursor()<br>
&nbsp;&nbsp;&nbsp; cur.execute(sql % (&quot;,&quot;.join(flds), value),[])<=
br>
&nbsp;&nbsp;&nbsp; if cur.rowcount&gt;0:<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; res=3Dcur.fetchone()<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for i,fld in enumerate(flds):<br=
>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; print cu=
r.description()[i],&quot;(&quot;,type(res[i]),&quot;):&quot;,res[i]<br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; getattr(=
blk,fld).value=3Dres[i]<br>
<br>
<br>
Best regards,<br>
Erny<br>
Spain<br>

------=_Part_2237_11802196.1123713211978--

--===============1211024838==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

_______________________________________________
Rekall-devel mailing list
[email protected]
http://www.mailman.a-i-s.co.uk/cgi-bin/mailman/listinfo/rekall-devel
--===============1211024838==--