1

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.


code as of comments script.py

import urllib
import sqlite3

conn = sqlite3.connect('MyBBDD.db')
c = conn.cursor()
c.execute ("UPDATE...")
conn.commit()
c.close()
conn.close()
2
  • Please show us the code from script.py. Are you using a relative or absolute path in that file?
    – elethan
    Commented Aug 12, 2016 at 16:17
  • elethan thanks for reply me so fast. script.py is like this: import urllib import sqlite3 conn = sqlite3.connect('MyBBDD.db') c = conn.cursor() c.execute ("UPDATE...") conn.commit() c.close() conn.close()
    – Tecnico
    Commented Aug 12, 2016 at 16:24

1 Answer 1

3

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')
1
  • Yes! Wok fine!! Thanks you very much :)
    – Tecnico
    Commented Aug 12, 2016 at 16:32

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.