Django is "unable to open database file"

Solution from NewbieMistakes

Make sure Apache can also write to the parent directory of the database. SQLite needs to be able to write to this directory.

Make sure each folder of your database file's full path does not start with number, eg. /www/4myweb/db (observed on Windows 2000).

If DATABASE_NAME is set to something like '/Users/yourname/Sites/mydjangoproject/db/db', make sure you've created the 'db' directory first.

Make sure your /tmp directory is world-writable (an unlikely cause as other thing on your system will also not work). ls /tmp -ald should produce drwxrwxrwt ....

Make sure the path to the database specified in settings.py is a full path.


I solved the error by changing the DATABASE_NAME to an absolute path: /var/www/apps/apps.db.

On a windows machine, backslash should be escaped like: C:\\path\\to\\database\\database_name.db.


DATABASE_NAME is deprecated. You must use the currently supported format. i.e.

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.sqlite3',
    'NAME': 'C:/ispdb.sqlite',
    'USER': '',
    'PASSWORD': '',
    'HOST': '',
    'PORT': ''

}

And also see other settings which are deprecated from the django website.:))