SQLite database gets locked by SELECT clause
Question: I have a python script which creates a database and then enters an infinite
loop which runs once per second quering the database with some selects.

At the same time I connect to the database with a sqlite cli and try to make
an update but I get a database is locked error.

Here the (anonimized) code of the script:

    
    
    import sqlite3
    import time
    
    con = sqlite3.connect(r'path\to\database.sqlite')
    
    con.execute('DROP TABLE IF EXISTS blah;')
    con.execute('CREATE TABLE blah;')
    con.execute('INSERT INTO blah;')
    
    con.commit()
    
    while True:
        result = con.execute('SELECT blah')
        print(result.fetchone()[0])
        time.sleep(1)
    


Answer: Python's `sqlite3` module tries to be clever and [manages transactions for
you](https://docs.python.org/2/library/sqlite3.html#sqlite3-controlling-
transactions).

To ensure that you can access the database from other threads/processes,
disable that (set `isolation_level` to `None`), and use explicit transactions,
when needed. Alternatively, call `con.commit()` whenever you are finished.

