Forums

"database is locked" error

Hello,

I followed instructions in "http://tutorial.pythonanywhere.com/django#tutorial-setting-up-a-new-django-app-on-pythonanywhere"

I got my "admin page working yesterday but when I tried to access it today I got a "database is locked" exception.

Also, I couldn't get my homepage to work even though I mimicked all steps.

What seems to be the problem ?

Hi Asmaamagdi,

You are using sqlite3 for your database? What this message means is that something went wrong during a write operation.
You have two options. If there was anything important in your databse (unlikely if you were just setting it up) then you could create a back up and then replace the existing db file with the backup. Instructions for that are here.

More simply you could delete the db file and run ./manage.py syncdb again from a bash shell. This should return your database file to a working and empty state.

Thanks Hansel, It worked :)

Here is an updated link and some sample code:

$ sqlite3 mydatabase.sqlite
sqlite> .backup main backup.sqlite
sqlite> .exit
$ mv mydatabase.sqlite old.sqlite
$ mv backup.sqlite mydatabase.sqlite

In general we would suggest not using sqlite for production code though. (and use MySQL that we provide for free instead)