Django says “Unable to open” SQLite3

First of all, make sure the db path in your settings file.

import os
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
        'NAME': os.path.join(PROJECT_ROOT, 'talktrack.sqlite'), # Or path to database file if using sqlite3.
        'USER': '',                      # Not used with sqlite3.
        'PASSWORD': '',                  # Not used with sqlite3.
        'HOST': '',                      # Set to empty string for localhost. Not used with sqlite3.
        'PORT': '',                      # Set to empty string for default. Not used with sqlite3.
    }
}

Then, check permissions below file and folders. (django needs full permissions)
1. db file.
i.e. yourapp.sqlite
2. /var/tmp
3. parent folder of db file
i.e. /var/www/yourapp
if the db file is in the folder. /var/www/yourapp/yourapp.sqlite

sudo chown -R user:group file-or-folder
Advertisements