SQLite Forum

How to circumvent "apsw.BusyError: BusyError: database is locked"?
Login
What about changing journal_mode from WAL to default? Is it harmful?

For the script, I don't know what I should test to conditionally use `PRAGMA journal_mode=WAL;`. Do you know how the code should be changed?

```
import apsw
conn = apsw.Connection(sys.argv[1])
c = conn.cursor()
c.execute('pragma busy_timeout=5;')
c.execute('PRAGMA journal_mode=WAL;')
c.execute('BEGIN IMMEDIATE;')
try:
        c.execute('CREATE TABLE IF NOT EXISTS sqlar(name TEXT PRIMARY KEY, mode INT, mtime INT, sz INT, data BLOB)')
        for (name, len_data, zlib_data) in n2d:
                c.execute('REPLACE INTO sqlar VALUES(?, ?, ?, ?, ?)', [name, 0, 0, len_data, zlib_data])
        c.execute('COMMIT')
except:
        c.execute('ROLLBACK')
        raise
```