sqlite3.ProgrammingError: You must not use 8-bit bytestrings unless you use a text_factory that can interpret 8-bit bytestrings

后端 未结 5 1331
佛祖请我去吃肉
佛祖请我去吃肉 2020-12-02 10:44

Using SQLite3 in Python, I am trying to store a compressed version of a snippet of UTF-8 HTML code.

Code looks like this:

...
c = connection.cursor()         


        
5条回答
  •  情深已故
    2020-12-02 11:23

    If you want to use 8-bit strings instead of unicode string in sqlite3, set approptiate text_factory for sqlite connection:

    connection = sqlite3.connect(...)
    connection.text_factory = str
    

提交回复
热议问题