Character Encoding Question
От | Don Parris |
---|---|
Тема | Character Encoding Question |
Дата | |
Msg-id | CAJ-7yonFRiBcaYVcccfF0zHjhNToK2aWrAVaeLW6Kj4Gk_tvcw@mail.gmail.com обсуждение исходный текст |
Ответы |
Re: Character Encoding Question
|
Список | psycopg |
Hi all,
I am using Psycopg2 with Python3 & PostgreSQL 9.1 with a database encoded as UTF-8 (Kubuntu 12.10). I have a question about the encoding and decoding, and why some fetch calls did what I wanted while fetchall() seemed to choke. I got the following error message when calling fetchall():UnicodeDecodeError: 'ascii' codec can't decode byte 0xe2 in position 9: ordinal not in range(128)
The traceback pointed to the fetchall() statement.
conn.set_client_encoding('LATIN9')
I tried that, but set the encoding to UTF-8 instead of the LATIN9, supposing that might be useful. Given the successful result, it appears that was just what the doctor ordered!
My first question is, is this really all I need to do - just set the client encoding? Or is there something else I need to do or be aware of?
My second question is why does fetchall() fail without setting the client encoding (while the other fetch calls work)?
Thanks!
Don
--
D.C. Parris, FMP, Linux+, ESL Certificate
Minister, Security/FM Coordinator, Free Software Advocate
D.C. Parris, FMP, Linux+, ESL Certificate
Minister, Security/FM Coordinator, Free Software Advocate
GPG Key ID: F5E179BE
В списке psycopg по дате отправления: