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

后端 未结 5 1442
独厮守ぢ
独厮守ぢ 2021-01-01 23:54

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 follo

5条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-01 23:57

    Try to change to this:

    cursor.execute("select * from musiclibrary where absolutepath = ?;",
        [unicode(filename,'utf8')])
    

    In your filename origin not encode with utf8, change utf8 to your encoding.

提交回复
热议问题