MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / begin_nested

Method begin_nested

lib/sqlalchemy/orm/session.py:1952–1976  ·  view source on GitHub ↗

Begin a "nested" transaction on this Session, e.g. SAVEPOINT. The target database(s) and associated drivers must support SQL SAVEPOINT for this method to function correctly. For documentation on SAVEPOINT transactions, please see :ref:`session_begin_nested`.

(self)

Source from the content-addressed store, hash-verified

1950 return trans # needed for __enter__/__exit__ hook
1951
1952 def begin_nested(self) -> SessionTransaction:
1953 """Begin a "nested" transaction on this Session, e.g. SAVEPOINT.
1954
1955 The target database(s) and associated drivers must support SQL
1956 SAVEPOINT for this method to function correctly.
1957
1958 For documentation on SAVEPOINT
1959 transactions, please see :ref:`session_begin_nested`.
1960
1961 :return: the :class:`.SessionTransaction` object. Note that
1962 :class:`.SessionTransaction` acts as a context manager, allowing
1963 :meth:`.Session.begin_nested` to be used in a "with" block.
1964 See :ref:`session_begin_nested` for a usage example.
1965
1966 .. seealso::
1967
1968 :ref:`session_begin_nested`
1969
1970 :ref:`pysqlite_serializable` - special workarounds required
1971 with the SQLite driver in order for SAVEPOINT to work
1972 correctly. For asyncio use cases, see the section
1973 :ref:`aiosqlite_serializable`.
1974
1975 """
1976 return self.begin(nested=True)
1977
1978 def rollback(self) -> None:
1979 """Rollback the current transaction in progress.

Calls 1

beginMethod · 0.95