SQLite, python, unicode, and non-utf data

后端 未结 5 638
死守一世寂寞
死守一世寂寞 2020-12-02 05:37

I started by trying to store strings in sqlite using python, and got the message:

sqlite3.ProgrammingError: You must not use 8-bit bytestrings unles

5条回答
  •  借酒劲吻你
    2020-12-02 05:57

    Of course there is. But your data is already broken in the database, so you'll need to fix it:

    >>> print u'Sigur Rós'.encode('latin-1').decode('utf-8')
    Sigur Rós
    

提交回复
热议问题