MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / begin_nested

Method begin_nested

lib/sqlalchemy/orm/session.py:1993–2017  ·  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

1991 return trans # needed for __enter__/__exit__ hook
1992
1993 def begin_nested(self) -> SessionTransaction:
1994 """Begin a "nested" transaction on this Session, e.g. SAVEPOINT.
1995
1996 The target database(s) and associated drivers must support SQL
1997 SAVEPOINT for this method to function correctly.
1998
1999 For documentation on SAVEPOINT
2000 transactions, please see :ref:`session_begin_nested`.
2001
2002 :return: the :class:`.SessionTransaction` object. Note that
2003 :class:`.SessionTransaction` acts as a context manager, allowing
2004 :meth:`.Session.begin_nested` to be used in a "with" block.
2005 See :ref:`session_begin_nested` for a usage example.
2006
2007 .. seealso::
2008
2009 :ref:`session_begin_nested`
2010
2011 :ref:`pysqlite_serializable` - special workarounds required
2012 with the SQLite driver in order for SAVEPOINT to work
2013 correctly. For asyncio use cases, see the section
2014 :ref:`aiosqlite_serializable`.
2015
2016 """
2017 return self.begin(nested=True)
2018
2019 def rollback(self) -> None:
2020 """Rollback the current transaction in progress.

Calls 1

beginMethod · 0.95