MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / SessionTransaction

Class SessionTransaction

lib/sqlalchemy/orm/session.py:858–1462  ·  view source on GitHub ↗

A :class:`.Session`-level transaction. :class:`.SessionTransaction` is produced from the :meth:`_orm.Session.begin` and :meth:`_orm.Session.begin_nested` methods. It's largely an internal object that in modern use provides a context manager for session transactions. Docum

Source from the content-addressed store, hash-verified

856
857
858class SessionTransaction(_StateChange, TransactionalContext):
859 """A :class:`.Session`-level transaction.
860
861 :class:`.SessionTransaction` is produced from the
862 :meth:`_orm.Session.begin`
863 and :meth:`_orm.Session.begin_nested` methods. It's largely an internal
864 object that in modern use provides a context manager for session
865 transactions.
866
867 Documentation on interacting with :class:`_orm.SessionTransaction` is
868 at: :ref:`unitofwork_transaction`.
869
870
871 .. versionchanged:: 1.4 The scoping and API methods to work with the
872 :class:`_orm.SessionTransaction` object directly have been simplified.
873
874 .. seealso::
875
876 :ref:`unitofwork_transaction`
877
878 :meth:`.Session.begin`
879
880 :meth:`.Session.begin_nested`
881
882 :meth:`.Session.rollback`
883
884 :meth:`.Session.commit`
885
886 :meth:`.Session.in_transaction`
887
888 :meth:`.Session.in_nested_transaction`
889
890 :meth:`.Session.get_transaction`
891
892 :meth:`.Session.get_nested_transaction`
893
894
895 """
896
897 _rollback_exception: Optional[BaseException] = None
898
899 _connections: Dict[
900 Union[Engine, Connection], Tuple[Connection, Transaction, bool, bool]
901 ]
902 session: Session
903 _parent: Optional[SessionTransaction]
904
905 _state: SessionTransactionState
906
907 _new: weakref.WeakKeyDictionary[InstanceState[Any], object]
908 _deleted: weakref.WeakKeyDictionary[InstanceState[Any], object]
909 _dirty: weakref.WeakKeyDictionary[InstanceState[Any], object]
910 _key_switches: weakref.WeakKeyDictionary[
911 InstanceState[Any], Tuple[Any, Any]
912 ]
913
914 origin: SessionTransactionOrigin
915 """Origin of this :class:`_orm.SessionTransaction`.

Callers 2

_beginMethod · 0.85
_autobegin_tMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected