Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #58473 > unrolled thread

Trouble with utf-8 values

Started byUlrich Goebel <ml@fam-goebel.de>
First post2013-11-05 02:27 +0100
Last post2013-11-05 02:27 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Trouble with utf-8 values Ulrich Goebel <ml@fam-goebel.de> - 2013-11-05 02:27 +0100

#58473 — Trouble with utf-8 values

FromUlrich Goebel <ml@fam-goebel.de>
Date2013-11-05 02:27 +0100
SubjectTrouble with utf-8 values
Message-ID<mailman.2037.1383614829.18130.python-list@python.org>
Hallo,

again: a python beginner problem... but I spent ours to solve it without 
success.

I have an object (a variable) name, which gets its value from a 
PostgreSQL database via a SELECT statement, an it sometimes has german 
special characters as ß, ä, ö...

Then I would like to insert that value into a table in a SQLite 
database. So I make a cursor cur on the table and prepare a SQL 
statement like this:

sql = 'insert into tbl values(?)'
cur.execute(sql, (name,))

That ends up with the exception, for example,

UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 6: 
ordinal not in range(128)

The "position 6" is exactly the position of the special character, ß in 
this case.

What to do?

Ulrich


-- 
Ulrich Goebel
Paracelsusstr. 120, 53177 Bonn

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web