<pre><code>sqlite&gt; DELETE FROM mails WHERE (`id` = 71);
SQL error: database is locked
</code></pre>

<p>How do I unlock the database so this will work?</p>

the SQLite db files are just files, so the first step would be to make sure it isn't read-only.  The other thing to do is to make sure that you don't have some sort of GUI SQLite DB viewer with the DB open.  You could have the DB open in another shell, or your code may have the DB open.  Typically you would see this if a different thread, or application such as SQLite Database Browser has the DB open for writing.