MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / _autobegin_t

Method _autobegin_t

lib/sqlalchemy/orm/session.py:1918–1936  ·  lib/sqlalchemy/orm/session.py::Session._autobegin_t
(self, begin: bool = False)

Source from the content-addressed store, hash-verified

1916 return {}
1917
1918 def _autobegin_t(self, begin: bool = False) -> SessionTransaction:
1919 if self._transaction is None:
1920 if not begin and not self.autobegin:
1921 raise sa_exc.InvalidRequestError(
1922 class="st">"Autobegin is disabled on this Session; please call "
1923 class="st">"session.begin() to start a new transaction"
1924 )
1925 trans = SessionTransaction(
1926 self,
1927 (
1928 SessionTransactionOrigin.BEGIN
1929 if begin
1930 else SessionTransactionOrigin.AUTOBEGIN
1931 ),
1932 )
1933 assert self._transaction is trans
1934 return trans
1935
1936 return self._transaction
1937
1938 def begin(self, nested: bool = False) -> SessionTransaction:
1939 class="st">"""Begin a transaction, or nested transaction,

Callers 10

beginMethod · 0.95
commitMethod · 0.95
prepareMethod · 0.95
_connection_for_bindMethod · 0.95
_before_attachMethod · 0.95
_flushMethod · 0.95
_bulk_save_mappingsMethod · 0.95
_modified_eventMethod · 0.80

Calls 1

SessionTransactionClass · 0.85