class SessionTransaction(TransactionalContext):
A .Session
-level transaction.
.SessionTransaction
is produced from the
_orm.Session.begin
and _orm.Session.begin_nested
methods. It's largely an internal
object that in modern use provides a context manager for session
transactions.
Documentation on interacting with _orm.SessionTransaction
is
at: :ref:`unitofwork_transaction`.
_orm.SessionTransaction
object directly have been simplified.See Also
.Session.begin
.Session.begin_nested
.Session.rollback
.Session.commit
.Session.in_transaction
.Session.in_nested_transaction
.Session.get_transaction
.Session.get_nested_transaction
Method | __init__ |
Undocumented |
Method | _assert_active |
Undocumented |
Method | _begin |
Undocumented |
Method | _connection_for_bind |
Undocumented |
Method | _get_subject |
Undocumented |
Method | _iterate_self_and_parents |
Undocumented |
Method | _prepare_impl |
Undocumented |
Method | _remove_snapshot |
Remove the restoration state taken before a transaction began. |
Method | _restore_snapshot |
Restore the restoration state taken before a transaction began. |
Method | _rollback_can_be_called |
indicates the object is in a state that is known to be acceptable for rollback() to be called. |
Method | _take_snapshot |
Undocumented |
Method | _transaction_is_active |
Undocumented |
Method | _transaction_is_closed |
Undocumented |
Method | close |
Undocumented |
Method | commit |
Undocumented |
Method | connection |
Undocumented |
Method | prepare |
Undocumented |
Method | rollback |
Undocumented |
Class Variable | _rollback_exception |
Undocumented |
Instance Variable | _connections |
Undocumented |
Instance Variable | _deleted |
Undocumented |
Instance Variable | _dirty |
Undocumented |
Instance Variable | _key_switches |
Undocumented |
Instance Variable | _new |
Undocumented |
Instance Variable | _parent |
Undocumented |
Instance Variable | _previous_nested_transaction |
Undocumented |
Instance Variable | _state |
Undocumented |
Instance Variable | nested |
Indicates if this is a nested, or SAVEPOINT, transaction. |
Instance Variable | session |
Undocumented |
Property | _is_transaction_boundary |
Undocumented |
Property | is_active |
Undocumented |
Property | parent |
The parent .SessionTransaction of this .SessionTransaction . |
Inherited from TransactionalContext
:
Class Method | _trans_ctx_check |
Undocumented |
Method | __enter__ |
Undocumented |
Method | __exit__ |
Undocumented |
Instance Variable | _outer_trans_ctx |
Undocumented |
Instance Variable | _trans_subject |
Undocumented |
Undocumented
Remove the restoration state taken before a transaction began.
Corresponds to a commit.
Restore the restoration state taken before a transaction began.
Corresponds to a rollback.
indicates the object is in a state that is known to be acceptable for rollback() to be called.
This does not necessarily mean rollback() will succeed or not raise an error, just that there is currently no state detected that indicates rollback() would fail or emit warnings.
It also does not mean that there's a transaction in progress, as it is usually safe to call rollback() even if no transaction is present.
bool
=
Indicates if this is a nested, or SAVEPOINT, transaction.
When .SessionTransaction.nested
is True, it is expected
that .SessionTransaction.parent
will be True as well.
The parent .SessionTransaction
of this
.SessionTransaction
.
If this attribute is None, indicates this
.SessionTransaction
is at the top of the stack, and
corresponds to a real "COMMIT"/"ROLLBACK"
block. If non-None, then this is either a "subtransaction"
or a "nested" / SAVEPOINT transaction. If the
.SessionTransaction.nested
attribute is True, then
this is a SAVEPOINT, and if False, indicates this a subtransaction.