module documentation

Undocumented

Class Atomic Guarantee the atomic execution of a given block.
Exception TransactionManagementError Transaction management is used improperly.
Function atomic Undocumented
Function clean_savepoints Reset the counter used to generate unique savepoint ids in this thread.
Function commit Commit a transaction.
Function get_autocommit Get the autocommit status of the connection.
Function get_connection Get a database connection by name, or the default database connection if no name is provided. This is a private API.
Function get_rollback Get the "needs rollback" flag -- for *advanced use* only.
Function mark_for_rollback_on_error Internal low-level utility to mark a transaction as "needs rollback" when an exception is raised while not enforcing the enclosed block to be in a transaction. This is needed by Model.save() and friends to avoid starting a transaction when in autocommit mode and a single query is executed.
Function non_atomic_requests Undocumented
Function on_commit Register `func` to be called when the current transaction is committed. If the current transaction is rolled back, `func` will not be called.
Function rollback Roll back a transaction.
Function savepoint Create a savepoint (if supported and required by the backend) inside the current transaction. Return an identifier for the savepoint that will be used for the subsequent rollback or commit.
Function savepoint_commit Commit the most recent savepoint (if one exists). Do nothing if savepoints are not supported.
Function savepoint_rollback Roll back the most recent savepoint (if one exists). Do nothing if savepoints are not supported.
Function set_autocommit Set the autocommit status of the connection.
Function set_rollback Set or unset the "needs rollback" flag -- for *advanced use* only.
Function _non_atomic_requests Undocumented
def atomic(using=None, savepoint=True, durable=False): (source)

Undocumented

def clean_savepoints(using=None): (source)

Reset the counter used to generate unique savepoint ids in this thread.

def commit(using=None): (source)

Commit a transaction.

def get_autocommit(using=None): (source)

Get the autocommit status of the connection.

def get_connection(using=None): (source)

Get a database connection by name, or the default database connection if no name is provided. This is a private API.

def get_rollback(using=None): (source)

Get the "needs rollback" flag -- for *advanced use* only.

@contextmanager
def mark_for_rollback_on_error(using=None): (source)

Internal low-level utility to mark a transaction as "needs rollback" when an exception is raised while not enforcing the enclosed block to be in a transaction. This is needed by Model.save() and friends to avoid starting a transaction when in autocommit mode and a single query is executed. It's equivalent to: connection = get_connection(using) if connection.get_autocommit(): yield else: with transaction.atomic(using=using, savepoint=False): yield but it uses low-level utilities to avoid performance overhead.

def non_atomic_requests(using=None): (source)

Undocumented

def on_commit(func, using=None): (source)

Register `func` to be called when the current transaction is committed. If the current transaction is rolled back, `func` will not be called.

def rollback(using=None): (source)

Roll back a transaction.

def savepoint(using=None): (source)

Create a savepoint (if supported and required by the backend) inside the current transaction. Return an identifier for the savepoint that will be used for the subsequent rollback or commit.

def savepoint_commit(sid, using=None): (source)

Commit the most recent savepoint (if one exists). Do nothing if savepoints are not supported.

def savepoint_rollback(sid, using=None): (source)

Roll back the most recent savepoint (if one exists). Do nothing if savepoints are not supported.

def set_autocommit(autocommit, using=None): (source)

Set the autocommit status of the connection.

def set_rollback(rollback, using=None): (source)

Set or unset the "needs rollback" flag -- for *advanced use* only. When `rollback` is `True`, trigger a rollback when exiting the innermost enclosing atomic block that has `savepoint=True` (that's the default). Use this to force a rollback without raising an exception. When `rollback` is `False`, prevent such a rollback. Use this only after rolling back to a known-good state! Otherwise, you break the atomic block and data corruption may occur.

def _non_atomic_requests(view, using): (source)

Undocumented