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

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

    You need to specify the encoding of filename for conversion to Unicode, for example: filename.decode('utf-8'). Just using unicode(...) picks the console encoding, which is often unreliable (and often ascii).

提交回复
热议问题