Skip to content

Commit

Permalink
Add notes on lock type / isolation level parameter.
Browse files Browse the repository at this point in the history
[skip ci]
  • Loading branch information
coleifer committed Oct 12, 2023
1 parent a219fd4 commit e04d237
Showing 1 changed file with 20 additions and 2 deletions.
22 changes: 20 additions & 2 deletions docs/peewee/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ Database
:returns: whether or not a transaction is currently open.
:rtype: bool

.. py:method:: atomic()
.. py:method:: atomic([...])
Create a context-manager which runs any queries in the wrapped block in
a transaction (or save-point if blocks are nested).
Expand All @@ -186,6 +186,15 @@ Database

:py:meth:`~Database.atomic` can also be used as a decorator.

Database-specific parameters:

:py:class:`PostgresqlDatabase` and :py:class:`MySQLDatabase` accept an
``isolation_level`` parameter. :py:class:`SqliteDatabase` accepts a
``lock_type`` parameter.

:param str isolation_level: Isolation strategy: SERIALIZABLE, READ COMMITTED, REPEATABLE READ, READ UNCOMMITTED
:param str lock_type: Locking strategy: DEFERRED, IMMEDIATE, EXCLUSIVE.

Example code::

with db.atomic() as txn:
Expand Down Expand Up @@ -273,11 +282,20 @@ Database
Roll back any changes made during a transaction begun with
:py:meth:`~Database.session_start`.

.. py:method:: transaction()
.. py:method:: transaction([...])
Create a context-manager that runs all queries in the wrapped block in
a transaction.

Database-specific parameters:

:py:class:`PostgresqlDatabase` and :py:class:`MySQLDatabase` accept an
``isolation_level`` parameter. :py:class:`SqliteDatabase` accepts a
``lock_type`` parameter.

:param str isolation_level: Isolation strategy: SERIALIZABLE, READ COMMITTED, REPEATABLE READ, READ UNCOMMITTED
:param str lock_type: Locking strategy: DEFERRED, IMMEDIATE, EXCLUSIVE.

.. warning::
Calls to ``transaction`` cannot be nested. Only the top-most call
will take effect. Rolling-back or committing a nested transaction
Expand Down

0 comments on commit e04d237

Please sign in to comment.