Collectives™ on Stack Overflow
Find centralized, trusted content and collaborate around the technologies you use most.
Learn more about Collectives
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
Learn more about Teams
Ask Question
Every SQLITE query I make usually goes fine, except I cannot seem to be able to update the DB.
db = sqlite3.connect("data.db")
cursor = db.cursor()
str_datetime = str(datetime.datetime.now())
cursor.execute("""UPDATE ads SET publish_end_datetime = ? WHERE ad_code = ?""", (str_datetime, 1411671200))
db.commit() # is this commit statement even necessary?
db.close()
I get the following operational error:
OperationalError Traceback (most recent call
last) in ()
3 str_datetime = str(datetime.datetime.now())
----> 5 cursor.execute("""UPDATE ads SET publish_end_datetime = ? WHERE ad_code = ?""", (str_datetime, 1411671200))
6 db.commit()
7 db.close()
OperationalError: database is locked
–
–
–
–
I think I've found the problem.
Whenever the DB is in use, a database.db-journal file is created in the same location. That's the main indicator that the DB is in use.
I have not found what was "using" my DB, but I've found how to solve my problem. It appears that OneDrive might have been the problem. I copied my data.db on the desktop, outisde of OneDrive, and I finally have been able to get the update statement to work.
I hope it helps other people.
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.