Tecnico Tecnico - 1 year ago 71
Python Question

Error using python and sqlite3

I have a directory (/home/usuario/Desktop/Example) with one database (MyBBDD.db) and the file (script.py) that run the command "UPDATE".
If in the terminal I'm in the directory "Example", script.py work fine but if Im not in the directory "Example" and I execute script.py like this:

python /home/usuario/Desktop/Example/script.py
" doesnt work fine, the error is: "no such table: name_table".
Somebody know what is the problem?
Thanks in advance.

Best regards.

Answer Source

When you create a connection object with sqlite3 in script.py, use the absolute file path, i.e.

con = sqlite3.connect('/home/usuario/Desktop/Example/MyBBDD.db')