sam
sam

Reputation: 19164

sqlite3.OperationalError: unable to open database file

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

Upvotes: 0

Views: 4855

Answers (5)

Codebender
Codebender

Reputation: 315

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.

Upvotes: 1

Graham Klyne
Graham Klyne

Reputation: 846

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

Upvotes: 1

Kristin Gannon
Kristin Gannon

Reputation: 99

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.

Upvotes: 1

Ramandeep Singh
Ramandeep Singh

Reputation: 5253

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.

Upvotes: 0

linuxeasy
linuxeasy

Reputation: 6489

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!

Upvotes: 1

Related Questions