Vote count:
0
I am using a one-line script calling the sqlite3 shell to update a value in a DB (this is on Windows 8.1 although that shouldn't matter here).
The script simply reads:
sqlite3 < update.sql
The update.sql-file contains:
.open "mydb.db"
UPDATE <args omitted for brevity>;
.save "mydb.db"
.exit
i.e. it opens the DB (according to the sqlite3-help that means: reads it into memory), applies the update and then wants to save the modified DB back to disk again.
But when I execute that script I get:
C:\>sqlite3 0<update.sql
.open "mydb.db"
UPDATE <args omitted for brevity>;
.save "mydb.db"
**Error: database is locked**
.exit
The reason - as I found out by googling around - seems to be that the UPDATE is run in a background thread, which keeps the DB locked. That means, when the save-command tries to write the DB back to disk, the DB is still locked.
I found no command in the sqlite3-shell to release that lock (or to wait until that lock gets released). So, what can I do to release that lock (or wait until it is released) and thus get this script to work properly?
The absences of such a command and thus the inability to save a DB after applying some modifications seems to make the sqlite3 shell utterly useless to me. I must be missing something fundamental here!?!
How to wait until sqlite3 unlocks DB?
Aucun commentaire:
Enregistrer un commentaire