[Answer]-Pysqlite DatabaseError: You must not use 8-bit bytestrings unless you use a text_factory

1đź‘Ť

The parameter to .execute() that causes the error is a Python bytestring instead of a unicode string like you said it was. Solution: create a unicode string instead: unicode(your_data, your_encoding). For most csv files, the encoding will eiter be “latin-1” or “uft-8”.

Using “unicode-escape” is almost certainly wrong. Its’s a Python-specific encoding meant to “Produce a string that is suitable as Unicode literal in Python source code” according to the docs (https://docs.python.org/2/library/codecs.html).

👤ghaering

Leave a comment