Trouble with utf-8 values

U

Ulrich Goebel

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top