pysqlite2: ProgrammingError - You must not use 8-bit bytestrings

Posted by rfkrocktk on Stack Overflow See other posts from Stack Overflow or by rfkrocktk
Published on 2010-05-14T22:44:44Z Indexed on 2010/05/14 23:04 UTC
Read the original article Hit count: 658

Filed under:
|
|

I'm currently persisting filenames in a sqlite database for my own purposes. Whenever I try to insert a file that has a special character (like é etc.), it throws the following error:

pysqlite2.dbapi2.ProgrammingError: 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.

When I do "switch my application over to Unicode strings" by wrapping the value sent to pysqlite with the unicode method like: unicode(filename), it throws this error:

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

Is there something I can do to get rid of this? Modifying all of my files to conform isn't an option.

© Stack Overflow or respective owner

Related posts about pysqlite

Related posts about sqlite