1. Michael Bayer
  2. sqlalchemy
  3. Issues

Issues

Issue #3089 wontfix

sqlite db with non-ascii characters in path

Scott Horowitz
created an issue

If you have a database path with non-ascii characters (e.g., "Á"), then sqlalchemy will fail with: "unable to open database file None None"

Python's sqlite3 also exhibits this behavior. However, you can workaround this in sqlite3 by doing:

import sqlite3, os
os.chdir("/path/with/non/ascii/character")
conn = sqlite3.connect("file.db")

This does not work with sqlalchemy, however, because the create_connect_args() method in sqlalchemy\dialects\sqlite\pysqlite3.py has the following code where an absolute path is always provided to sqlite:

        if filename != ':memory:':
            filename = os.path.abspath(filename)

If this code is removed, then the workaround works as expected.

That said, it will not resolve the issue of non-ascii characters in the filename itself, just the path.

Comments (3)

  1. Michael Bayer repo owner

    the abspath is from #2036, if the application changes the current directory then the URL fails.

    As this is an upstream bug with an easy workaround (use create_engine("sqlite://", creator=lambda: sqlite3.connect("whatever"))) I am -1 on SQLAlchemy getting into this. Python's issues with non-unicode filepaths (is this on Py3K at least? my understanding is that Py2k doesn't have issues like this) are a much bigger issue than SQLAlchemy.

  2. Log in to comment