SQLite Forum

Take control over the database for checkpointing and reading it
Login
That won't work because checkpointing can't be done inside a transaction.
You could retry in a loop until you win the race (pseudocode):

```
    dosql("pragma wal_checkpoint(truncate); begin immediate;")
    while (WAL file exists and is nonempty)
        dosql("rollback; pragma wal_checkpoint(truncate); begin immediate;")
```