Skip site navigation (1) Skip section navigation (2)

Re: latin-1 to utf8 in python

From: Tino Wildenhain <tino(at)wildenhain(dot)de>
To: anil maran <anilmrn(at)yahoo(dot)com>
Cc: pgsql-www(at)postgresql(dot)org
Subject: Re: latin-1 to utf8 in python
Date: 2006-08-03 07:06:52
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-www
anil maran schrieb:
> postgres takes utf8
> pls help me solve this thanks a lot
> some data is in latin-1 so postgres
> crashes

hm. "crashes" isnt quite correct, it
would "bark" or something, however ;)

> with
> psycopg2.ProgrammingError at /todo/38
> invalid byte sequence for encoding "UTF8": 0x92
> ariable         Value
> args
> ("INSERT INTO xdaad(nt, nn, tadadid, email) VALUES (%s, %s, %s, %s); SELECT
> currval('comments_id_seq')", ['co-worker\x92snd I\x92ll get the 
> .\r\n\r\n \r\n\r\nAeF\r\n\r\n\r\n\r\n \r\n\r\n', '121', '38', '... 
> <>']) 
> <>

Well you either recode in python:


or set your client-encoding for postgres, so
postgres does the conversion.

Look into psycopg api how to do this on connect
or just issue:

just after connect.

Tino Wildenhain

In response to

pgsql-www by date

Next:From: Joshua D. DrakeDate: 2006-08-04 18:11:15
Subject: Re: ...
Previous:From: Marc G. FournierDate: 2006-08-03 06:45:36
Subject: Re: is down

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group