#18661 closed Bug (invalid)

special characters like "é" or "è" in sqlite3 file path raise a "sqlite3.OperationalError: unable to open database file"

Reported by: oncleben31 Owned by: nobody
Component: Database layer (models, ORM) Version: 1.4
Severity: Normal Keywords: windows
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: yes Patch needs improvement: no
Easy pickings: no UI/UX: no


If my sqlite3 db file path have a "é" char, the "syncdb" action raise an error :
"sqlite3.OperationalError: unable to open database file"

I use in my settings os.path to create the path to this file on Windows. If this char is replaced by "e", syncdb is OK

Attachments (0)

Change History (4)

comment:1 Changed 21 months ago by claudep

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset

Is your "é" inside a Unicode string in your settings?

comment:2 Changed 20 months ago by javier@…

  • Keywords windows added
  • Needs tests set

Under linux, django will run fine with a sqlite database with a non-ascii pathname. However, it will print out a UnicodeWarning. This is the output of django runserver:

Django version 1.5.dev20120820010350, using settings 'ticket18661.settings'
Development server is running at
Quit the server with CONTROL-C.
/home/kandinski/.virtualenvs/django-bug-18661/src/django/django/db/backends/sqlite3/ UnicodeWarning: Unicode unequal comparison failed to convert both arguments to Unicode - interpreting them as being unequal
  if self.settings_dict['NAME'] != ":memory:":
[20/Aug/2012 01:25:08] "GET /admin/ HTTP/1.1" 200 3301
[20/Aug/2012 01:26:06] "GET /admin/auth/user/ HTTP/1.1" 200 6059
[20/Aug/2012 01:26:06] "GET /admin/jsi18n/ HTTP/1.1" 200 2164
[20/Aug/2012 01:26:13] "GET /admin/auth/user/add/ HTTP/1.1" 200 4615
[20/Aug/2012 01:26:13] "GET /admin/jsi18n/ HTTP/1.1" 200 2164
[20/Aug/2012 01:26:25] "POST /admin/auth/user/add/ HTTP/1.1" 302 0
[20/Aug/2012 01:26:25] "GET /admin/auth/user/2/ HTTP/1.1" 200 12995
[20/Aug/2012 01:26:25] "GET /admin/jsi18n/ HTTP/1.1" 200 2164

And a snippet from my settings:

# Django settings for ticket18661 project.
# coding: utf8
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.

comment:3 Changed 20 months ago by akaariai

The settings snippet seems to be missing the most important part of the information, the database's NAME. Make sure the name is an unicode string, something like this:

    'NAME': u'name_containing_é'

comment:4 Changed 20 months ago by kmtracey

  • Resolution set to invalid
  • Status changed from new to closed

I have verified that so long as the database name string is unicode (prefixed with u'', or in a file with from __future__ import unicode_literals), a sqlite file name with non-ascii characters works fine, on Windows. Tried 1.4 and current master, on current master tried both py2 and py3. The unicode warning noted above only happens when the DB name string is not unicode.

Add Comment

Modify Ticket

Change Properties
<Author field>
as closed
as The resolution will be set. Next status will be 'closed'
The resolution will be deleted. Next status will be 'new'

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.