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

后端 未结 5 1487
独厮守ぢ
独厮守ぢ 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:05

    You figured this out already, but:

    I don't think you could actually get that ProgrammingError exception from cursor.execute("select * from musiclibrary where absolutepath = ?;", [filename.decode("utf-8")]), as the question currently states.

    Either the utf-8 decode would explode, or the cursor.execute call would be happy with the result.

提交回复
热议问题