Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 673 Vote(s) - 3.53 Average
  • 1
  • 2
  • 3
  • 4
  • 5
sqlite3.OperationalError: unable to open database file

#1
I get this error when setting up a server in Django. It is sqlite3 which means it should create the .db file but it doesn't seem to be doing so. I've stipulated SQLite as the backend and an absolute file path for where to put it, but no luck.

Is this a bug or am I doing something incorrect? (Was just thinking, is the absolute file path specified differently in Ubuntu?)

Here is the beginning of my settings.py file:


# Django settings for OmniCloud project.

DEBUG = True
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Your Name', '[email protected]'),
)

MANAGERS = ADMINS

DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'postgresql', 'mysql', 'sqlite3' or 'oracle'.
'NAME': '~/Harold-Server/OmniCloud.db', # 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.
}
}
Reply

#2
You haven't specified the absolute path - you've used a shortcut , `~`, which might not work in this context. Use `/home/yourusername/Harold-Server/OmniCloud.db` instead.
Reply

#3
I faced exactly same issue. Here is my setting which worked.

'ENGINE': 'django.db.backends.sqlite3',
'NAME': '/home/path/to/your/db/data.sqlite3'

Other setting in case of sqlite3 will be same/default.
And you need to create data.sqlite3.
Reply

#4
use this type it works for me .
windows 7 with python 2.7 and django 1.5

'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'C:\\tool\\mysite\\data.db',

hope its works...

Reply

#5
You need to use full path instead of `~/`.

In your case, something like `/home/harold/Harold-Server/OmniCloud.db`.
Reply

#6
[Django NewbieMistakes][1]

> PROBLEM You're using SQLite3, your DATABASE_NAME is set to the
> database file's full path, the database file is writeable by Apache,
> but you still get the above error.
>
> SOLUTION 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.
>
> Also make sure the file is present where you expect it to be.


[1]:

[To see links please register here]

Reply

#7
In my case the sqlite db file `db.sqlite3` was stored in the `DocumentRoot` of apache. So, even after setting the following permissions it didn't work:

sudo chown www-data:www-data /path/to/db-folder
sudo chown www-data:www-data /path/to/db-folder/sqlite-db.db

Finally when i moved `db.sqlite3` to a newly created folder `dbfolder` under `DocumentRoot` and gave the above permissions, and it worked.
Reply

#8
I had this problem serving with Apache and found that using the absolute path to the sqlite3 db in my .env `////` as opposed to using the relative path `///` fixed the problem. All of the permissions and ownership mentioned above are necessary as well.
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through