MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / after_commit

Method after_commit

lib/sqlalchemy/orm/events.py:1846–1880  ·  view source on GitHub ↗

Execute after a commit has occurred. .. note:: The :meth:`~.SessionEvents.after_commit` hook is *not* per-flush, that is, the :class:`.Session` can emit SQL to the database many times within the scope of a transaction. For interception of the

(self, session: Session)

Source from the content-addressed store, hash-verified

1844 """
1845
1846 def after_commit(self, session: Session) -> None:
1847 """Execute after a commit has occurred.
1848
1849 .. note::
1850
1851 The :meth:`~.SessionEvents.after_commit` hook is *not* per-flush,
1852 that is, the :class:`.Session` can emit SQL to the database
1853 many times within the scope of a transaction.
1854 For interception of these events, use the
1855 :meth:`~.SessionEvents.before_flush`,
1856 :meth:`~.SessionEvents.after_flush`, or
1857 :meth:`~.SessionEvents.after_flush_postexec`
1858 events.
1859
1860 .. note::
1861
1862 The :class:`.Session` is not in an active transaction
1863 when the :meth:`~.SessionEvents.after_commit` event is invoked,
1864 and therefore can not emit SQL. To emit SQL corresponding to
1865 every transaction, use the :meth:`~.SessionEvents.before_commit`
1866 event.
1867
1868 :param session: The target :class:`.Session`.
1869
1870 .. seealso::
1871
1872 :meth:`~.SessionEvents.before_commit`
1873
1874 :meth:`~.SessionEvents.after_begin`
1875
1876 :meth:`~.SessionEvents.after_transaction_create`
1877
1878 :meth:`~.SessionEvents.after_transaction_end`
1879
1880 """
1881
1882 def after_rollback(self, session: Session) -> None:
1883 """Execute after a real DBAPI rollback has occurred.

Callers 1

commitMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected