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

后端 未结 5 1482
独厮守ぢ
独厮守ぢ 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-02 00:01

    Have you tried to pass the unicode string directly:

    cursor.execute("select * from musiclibrary where absolutepath = ?;",(u'namé',))
    

    You will need to add the file encoding at the beginning of the script:

    # coding: utf-8
    

提交回复
热议问题