Reputation: 585
I'm using Flask server in a Raspberry Pi with archlinux arm.
I have one script called rest.py wich contains the necessary to connect with the BDD:
(...)
DATABASE = 'stuff.db'
(...)
top.sqlite_db = sqlite3.connect(app.config['DATABASE'])
(etc)
If I execute the file.py the servers runs propertly, it establish the connection and then you can do the RESTs calls perfectly, you can GET, POST, etc.
But, when I execute the file.py using an script:
#!/bin/sh
sudo python file.py
..doesn't work. I get the following error: sqlite3.OperationalError: no such table: user
I've tried to grant absolute permissions to all files (chmod 777..., I know its not a good practice but I don't know what to do... ). So directory /tmp and the parent directory of the file.py and stuff.db are with full permissions.
I've also tried to eliminate the DBB and re-create it. Still the same.
Any idea guys?
Thank you for any help.
Upvotes: 0
Views: 2698
Reputation: 134
I meet a similar problem:
conn = sqlite3.connect('test.db')
c = conn.cursor()
c.execute("UPDATE COMPANY set SALARY = 25000.00 where ID=1")
conn.commit()
conn.close()
Then I add a line of code after "c = conn.cursor()":
conn.commit()
The problem is solved.
Upvotes: 1