Note that there are some explanatory texts on larger screens.

plurals
  1. POeffectively unlocking an SQLite database
    text
    copied!<p>I have a program which frequently crashes (Zotero), leaving its SQLite database locked and inaccessible for use by the restarted program unless I reboot (which I really want to avoid). So this does not work (using the generic name, <code>db.sqlite</code> in place of the actual file in my case, <code>zotero.sqlite</code>):</p> <pre><code>sqlite3 db.sqlite sqlite&gt; .backup main backup.sqlite Error: database is locked </code></pre> <p>Based on an answer <a href="https://stackoverflow.com/questions/151026/how-do-i-unlock-a-sqlite-database/1027493#1027493">here</a>, I tried:</p> <pre><code>echo ".dump" | sqlite3 db.sqlite | sqlite3 db.sqlite2 mv db.sqlite2 db.sqlite </code></pre> <p><code>db.sqlite2</code> is 0KB so this obviously did not work. Inspired by <a href="https://groups.google.com/forum/?fromgroups=#!topic/notecase-pro/tFJ58lBFp5o" rel="nofollow noreferrer">another thread</a>, I also tried </p> <pre><code>echo '.dump' | sqlite3 db.sqlite &gt; db.dump cat db.dump | sqlite3 db.sqlite2 mv db.sqlite2 db.sqlite </code></pre> <p>which leads to <code>db.sqlite2</code> which is slightly smaller in filesize to <code>db.sqlite</code>, and Zotero (the file which requires the database) was not able to recognize its contents.</p> <p>So this seems like a very brute force way of doing it, but worked:</p> <pre><code>cp -pv db.sqlite db.sqlite2 rm -f db.sqlite mv db.sqlite2 db.sqlite </code></pre> <p>I wonder if there are any drawbacks to this solution and why the other methods are proposed before this one.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload