Recently, I’m working on my Skypiea project which is powered by SQLite3 and Python (as CGI script). Yesterday I encountered a program: When the web server ran a CGI script which would update the database, I got an error message said “sqlite3.OperationalError: unable to open database file“.

I searched the web and Google told me I need to specify the full path (no ~ or $HOME etc.) of the database file and the web server needs the write permission to the file. Sure, I actually had done both before the exception occurred.
Having being pissed for a while, I finally figured out what was wrong here: The web server needs the write permission to not only the database file, but also the containing directory of that file.
Yea, just simple like that.
This had me occupied for an entire afternoon. I was convinced it was a concurrency problem that mutated into a file locking/access error until I found your explanation. Thank you so much!
Thanks!
:)
Thanks for the great tip.
Very subtle….
;o))
Thanks. You really helped me ;)
You saved my day!!!
I ran into the same problem today.
Thanks!! Good your page is the first in google results.
Actually that makes sense, I guess sqlite creates a temporary file in the directory and rewrites the old file with the temporary on commit.
yeah..thx for the information..
i have a same problem..
look like, i must try other idea..so the the DB not error anymore
Thanks! Full path required…
Thank you!! Write permissions on the db file AND its container! Who would have thought?!!
I am developing an application for a service desk manager and
it uses a storage platform SqlLite, broke the
head all afternoon to find very little detail that just taking everyone’s patience.
Thanks for the help.
Brazil – SP
Thank you guys, I’m glad this article is helpful!
Thanks for posting this hint so that google could find it for me :-)
Reinout
Thanks, that was it.