I made a python script which should start when I start my PC in order to do that I created a simple .bat file like this. But now I have a problem because why ever windows isn't able to open the database connection on startup. I tried it like this:
conn = sqlite3.connect('DB\Todos.db')
When I execute the baatch file normaly everything works but when windows starts it on startup this error comes up:
Traceback (most recent call last):
File "Path to my file", line 41, in <module>
conn = sqlite3.connect('DB\Todos.db')
sqlite3.OperationalError: unable to open database file
Of course where "Path to my file" is the normal path. Thanks for your help
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:
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.