Undocumented
Class | 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_rollback |
Get the "needs rollback" flag -- for advanced use only. |
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. |
Class | Atomic |
Guarantee the atomic execution of a given block. |
Function | _non_atomic_requests |
Undocumented |
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 | mark_for_rollback_on_error |
No summary |
func
to be called when the current transaction is committed.
If the current transaction is rolled back, func
will not be called.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.
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.