Search code examples
pythonpython-2.7sqlitepygtk

PythonGTK - Can't write special characters into database


I wrote the following program that writes into a sqlite3 table:

https://www.adrive.com/public/sJZKt3/program.py

It works fine except when trying to save language specific characters, for example:

Ää,ß, ç

When trying to insert into the table I get following error message:

SQL Error

You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings (like text_factory = str). It is highly recommended that you instead just switch your application to Unicode strings.

How can I fix that?


Solution

  • change text to unicode so you can insert

    text = "äöü"
    text = text.decode("utf8")