dimanche 6 mars 2016

Python sqlite3 connect with special characters in path

I have an application that is compiled with PyInstaller that uses a sqlite database. Everything works fine until a user with special characters in their name runs the software. Even simple code like this:

import sqlite3
path = "C:\Users\Jøen\test.db"

db = sqlite3.connect(db)

Results in a traceback:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
sqlite3.OperationalError: unable to open database file

I have tried all kinds of combinations including using chardet to detect the encoding and then converting to UTF-8 but that didn't work either. All of my usual Python encoding/decoding tricks are failing me at this point.

Has anyone successfully opened a SQLite DB in Python that has special characters in a path?

Aucun commentaire:

Enregistrer un commentaire