0

I am new in Django. I got the following error while working with it.
I am not able to solve it yet.
Can anyone tell me what needs to be done?

sqlite3.OperationalError: unable to open database file

5 Answers 5

1

The error says it all. Do you have your sqlite DB file in place? is it being referred rightly? You need to create/correct your sqlite DB file, so that your framework can find and load it correctly!

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

2 Comments

database already present.DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'bdu-celery', 'USER': 'django', 'PASSWORD': 'hello' } }
@sam: The config you have put is of PostGre, but your framework seems to be using sqlite. You need to check in your framework, where at all is it referring sqlite config.
1

I'm a beginner, too, and had a similar problem. The .db file will created for you when you run python manage.py syncdb. From your terminal window, just be sure that you're located in the same folder as the manage.py file in your directory structure. From this location, I was able to successfully create the necessary tables. The settings.py file will have already been created when you initially set the project up.

Comments

1

It appears that python manage.py syncdb will create the database file, but requires the directory used to already exist.

Comments

1

I had a similar problem at sometime. Error: sqlite3.OperationalError: unable to open database file and yet my settings.py pointed to a postgres database. It was just a mistake, I had moved my project directory which previously used sqlite. The new one(moved) used postgres but my uwsgi server still pointed to the old project directory.

If you are using more than one server in my case was using nginx and uwsgi, it's a good idea check both config files.

Comments

0

Make a File "settings.py" in the folder where your "manage.py" is there..

In the settings.py , change the following settings :

DATABASE_ENGINE = 'sqlite3'           # 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
DATABASE_NAME = '[your_database_name]'             # Or path to database file if using sqlite3.
DATABASE_USER = ''             # Not used with sqlite3.
DATABASE_PASSWORD = ''         # Not used with sqlite3.

N you are good to go..!!

Note : your database file will stored in your project folder.

2 Comments

already I have written as DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'bdu-celery', 'USER': 'django', 'PASSWORD': 'hello' } }
I dont know what you are doing...Configuration says "u are using postgresql"...but error saying "u are using SQLITE" ..i am not able to help by just seeing the question...please post detailed Error Info..!!

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.