Re: Encoding problems with cursor.execute

Mike Richardson <mike-1gTsUfBLqWsG2Il/[email protected]> Tue, 16 Aug 2005 16:01:06 +0100
Newsgroups gmane.comp.db.rekall.devel
Message-ID <[email protected]>
On Wednesday 10 August 2005 23:33, Ernesto Revilla wrote:
> Hello.
>
> 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.

Abel is doing some great stuff to get unicode working with python, so a bunch 
of stuff in this area is about to get sorted ....

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

-- 
Regards
Mike

http://www.rekallrevealed.org
*THE* GPL/Open Source database front end for Linux and Windows.