Skip to content

Commit

Permalink
OperationalError: database table is locked fix
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Aug 31, 2023
1 parent 4c3ef03 commit 9cead33
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions docs/internals.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,7 @@ For example:
def delete_and_return_count(conn):
conn.execute("delete from some_table where id > 5")
conn.commit()
return conn.execute(
"select count(*) from some_table"
).fetchone()[0]
Expand All @@ -1028,6 +1029,8 @@ The value returned from ``await database.execute_write_fn(...)`` will be the ret

If your function raises an exception that exception will be propagated up to the ``await`` line.

If you see ``OperationalError: database table is locked`` errors you should check that you remembered to explicitly call ``conn.commit()`` in your write function.

If you specify ``block=False`` the method becomes fire-and-forget, queueing your function to be executed and then allowing your code after the call to ``.execute_write_fn()`` to continue running while the underlying thread waits for an opportunity to run your function. A UUID representing the queued task will be returned. Any exceptions in your code will be silently swallowed.

.. _database_close:
Expand Down

0 comments on commit 9cead33

Please sign in to comment.