Re: Weird unicode problem

From: Daniele Varrazzo <daniele(dot)varrazzo(at)gmail(dot)com>
To: Dick Kniep <dick(at)lindix(dot)nl>
Cc: "psycopg(at)postgresql(dot)org" <psycopg(at)postgresql(dot)org>
Subject: Re: Weird unicode problem
Date: 2015-04-15 14:13:57
Message-ID: CA+mi_8Z0m8yuNKL6yobPK8_Pm6qS65hzWr_t=9k1E+pfeO-=Gg@mail.gmail.com
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: psycopg

On Wed, Apr 15, 2015 at 2:50 PM, Dick Kniep <dick(at)lindix(dot)nl> wrote:
> DataError: character with byte sequence 0xe2 0x82 0xac in encoding "UTF8" has no equivalent in encoding "LATIN1"

This is a PostgreSQL error: most likely your connection encoding is in
LATIN1 instead of UTF8. Proof is also that you get the error on
execute (which is normally when the data is transferred to psycopg)
and not on fetch*() (when the typecasters are applied).

Try running "show client_encoding" in you database in psql to check if
this is the case. If not, there could be something in your python code
changing the encoding: check the value of cnn.encoding where the code
is executed.

The client encoding can be changed in psycopg with a
cnn.set_client_encoding('utf8').

-- Daniele

In response to

Browse psycopg by date

  From Date Subject
Next Message Vamsi Krishna Reddy -T (vamsredd - TATA CONSULTANCY SERVICES LIMITED at Cisco) 2015-04-17 18:27:08 Need help with the installation of psycopg2 module in a python virtual env
Previous Message Dick Kniep 2015-04-15 13:50:28 Weird unicode problem