Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

django.db.utils.OperationalError: unable to open database file #48

Closed
mariodev opened this issue Dec 10, 2013 · 2 comments
Closed

django.db.utils.OperationalError: unable to open database file #48

mariodev opened this issue Dec 10, 2013 · 2 comments

Comments

@mariodev
Copy link

I create django project using the command given in the docs:

django-admin.py startproject mysite -v2 --template https://github.com/jezdez/django-configurations/archive/templates/1.6.x.zip

I do:

manage.py syncdb

This happens:

File "/home/mario/Envs/danny/local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py", line 346, in get_new_connection
conn = Database.connect(**conn_params)
django.db.utils.OperationalError: unable to open database file

I think the error is due to this part inside templates/1.6.x/project_name/settings.py:

DATABASES = values.DatabaseURLValue('sqlite://%s' % os.path.join(BASE_DIR, 'db.sqlite3'), environ=True)

On my ubuntu BASE_DIR points to /home/mario.., so the db url takes value of:

sqlite:///home/mario..

in this case django is trying to open home/mario.. (notice no starting slash). Since it cannot open the file, it throws db error.

To solve it, I use three slashes instead of two (sqlite:///%s), which seems to work fine in ubuntu and windows. But I'm not sure if that's the best solution.

jezdez added a commit that referenced this issue Jan 16, 2014
@jezdez jezdez closed this as completed Jan 16, 2014
@jezdez
Copy link
Member

jezdez commented Jan 16, 2014

Good catch! Thanks :)

@allexiusw
Copy link

I solved it by changing the directory of my db, the thing is that some of my team members changed the manage.py to a top position and the relative path wasn't properly configured.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants