3

I get the error

    OperationalError: unable to open database file

The path leading to my .db file is

    ~/Development/Django/django_prac/practice/database

Here is my Settings.py

    DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
    'NAME': '/Home/Development/Django/django_prac/practice/database/practice.db',                      # Or path to database file if using sqlite3. 
      # The following settings are not used with sqlite3:
    'USER': '',
    'PASSWORD': '',
    'HOST': '',                      # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
    'PORT': '',                      # Set to empty string for default.
        }
    }

I have also tried

    ~/Development/Django/django_prac/practice/database$ 

in my 'NAME' but yet same error occurs

11
  • 3
    Did you write Home but you wanted home? Commented Jul 22, 2013 at 12:02
  • 1
    First, you should simply check if the file exists, like "ls /Home/Development/Django/django_prac/practice/database/practice.db" Commented Jul 22, 2013 at 12:05
  • 1
    Have you run ´syncdb´? Commented Jul 22, 2013 at 12:08
  • 1
    ok, what happens if you just try "practice.db" ? Commented Jul 22, 2013 at 12:14
  • 1
    Are you using Apache? In this case, check code.djangoproject.com/wiki/… - you should anyway check if the user running the project has enough permissions to open the file. Commented Jul 22, 2013 at 12:16

1 Answer 1

3

OK, that is my suggestion:

DATABASES = {
'default': {
    'ENGINE': 'django.db.backends.sqlite3', 
    'NAME': 'practice.db', # Just the name
    'USER': '',
    'PASSWORD': '',
    'HOST': '',             
    'PORT': '',             
        }
    }

I think you maybe have an error in the path, try pwd over /Home/Development/Django/django_prac/practice/database/ directory and copy the output. Then plus the db name

hope helps

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.