Of course this show that the system cannot find the specified file, this are the reason to they can’t open the database file. If your program is in DB folder, you can just use
conn = sqlite3.connect('Todos.db')
instead. And, the most recommended if is for personal purposes, is that you use the entire path, like conn = sqlite3.connect('X:\MyDB\SQLite\Todos.db')
. The output error sqlite3.OperationalError: unable to open database file
begins, normally, with these errors below:
- System cannot find the file.
- System cannot open the file.
- System doesn’t have the permission to the file (or you don’t have).
- System doesn’t have READ permissions.
If cannot open find the file, move your script or your directory to the place that the file is. It’s economize code, is much better than insert the full path, because if you have making the program to someone, is harder to say where the program is, and he/she will, probably, change the code, etc. But if everything is on a same folder, is a lot easy.
If cannot open the file, probably is corrupted; the program cannot read this ext of file or is not a program that he recognize. Or you don’t pay the program.
If don’t have permission to the file, you need to start the program as ADMINISTRATOR, if it doesn’t work, search in the internet how to give permissions to an .(yourext).
For least, READ permissions is right on the file. Some files has an attrib, the “-r”, the Read-only file attribute, remove it with an PROMPT (CMD) with admin rights, being in the folder of the file and typing attrib -r -s -h yourfile.ext
, it removes the read-only, system and hidden file attributes.
If everything doesn’t work, the file is corrupted. Sorry.
CLICK HERE to find out more related problems solutions.