I would like to run a script continuously. The initial script is like this:
- connectionDB = sqlite3.connect("database.db")
- cursorDB = connectionDB.cursor()
- while True:
- insert an item in the sqlite database
- connectionDB.commit() and go back to step 3
So a scheduled task seems appropriate. I used to be free user and run this script daily. However, the task was killed after approximately 3 hours. Now I upraded to a payer account and I tried to use the exact same script but running the task hourly. However, in the task log, I get this approximately every hour:
sqlite3.OperationalError: database is locked
For me it's either due to a combination of the following:
- The task is not killed exactly after 1 hour so that the 2nd task cannot complete.
- I don't close the sqlite connection (because the initial script is an infinite loop)
So how should I do to run this script (that pulls data from the web and insert it into a database every 5minutes) ? Shall I modify the script itself by replacing the "while" by a "for" with a number of iterations equals to int(60/5), close the database connection at the end of the script, and run it hourly ?