Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>All you need to do is <a href="http://docs.python.org/library/sqlite3.html#sqlite3.connect" rel="nofollow noreferrer"><code>connect</code></a> to the database - you can do anything you want to with it then.</p> <pre><code>from sqlite3 import connect conn = connect("/path/to/your/sqlite.db") # Do what you need to with the database here # Changes (inserts, updates, etc) will be persisted # to disk whenever you commit a transaction. </code></pre> <p>If you need to be able to run a series of commands and roll them all back if one does not succeed you should use a <a href="http://sqlite.org/lang_transaction.html" rel="nofollow noreferrer">transaction</a>.</p> <p>If you need to make a copy of the existing database, make alterations to it and then save it somewhere else <em>only if the alterations succeed</em> then you can do one of the following things:</p> <ul> <li>Create an in-memory database and then use SQLite's <a href="http://sqlite.org/lang_attach.html" rel="nofollow noreferrer"><code>ATTATCH DATABASE</code></a> command to attach the existing database to the new in-memory database. Once you have copied all of the data over from the existing database into the in-memory database and transformed it you can attach a new database and copy everything over again.</li> <li>Copy the existing database <strong>file</strong>, attempt to make alterations to it, and delete the new file if the operations did not succeed.</li> <li>Use <code>sqlite3</code>'s <a href="http://docs.python.org/library/sqlite3.html#sqlite3.Connection.iterdump" rel="nofollow noreferrer"><code>Connection.iterdump</code></a> to get the contents of the tables as a SQL script which you can then pass to <a href="http://docs.python.org/2/library/sqlite3.html#sqlite3.Cursor.executescript" rel="nofollow noreferrer"><code>sqlite3.Cursor.executescript</code></a> as <a href="https://stackoverflow.com/questions/3850022/python-sqlite3-load-existing-db-file-to-memory/10856450#10856450">this answer suggests</a> (using either an in-memory or an on-disk connection string for your new database).</li> </ul>
 

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