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)
| 1855 | """ |
| 1856 | |
| 1857 | def after_commit(self, session: Session) -> None: |
| 1858 | """Execute after a commit has occurred. |
| 1859 | |
| 1860 | .. note:: |
| 1861 | |
| 1862 | The :meth:`~.SessionEvents.after_commit` hook is *not* per-flush, |
| 1863 | that is, the :class:`.Session` can emit SQL to the database |
| 1864 | many times within the scope of a transaction. |
| 1865 | For interception of these events, use the |
| 1866 | :meth:`~.SessionEvents.before_flush`, |
| 1867 | :meth:`~.SessionEvents.after_flush`, or |
| 1868 | :meth:`~.SessionEvents.after_flush_postexec` |
| 1869 | events. |
| 1870 | |
| 1871 | .. note:: |
| 1872 | |
| 1873 | The :class:`.Session` is not in an active transaction |
| 1874 | when the :meth:`~.SessionEvents.after_commit` event is invoked, |
| 1875 | and therefore can not emit SQL. To emit SQL corresponding to |
| 1876 | every transaction, use the :meth:`~.SessionEvents.before_commit` |
| 1877 | event. |
| 1878 | |
| 1879 | :param session: The target :class:`.Session`. |
| 1880 | |
| 1881 | .. seealso:: |
| 1882 | |
| 1883 | :meth:`~.SessionEvents.before_commit` |
| 1884 | |
| 1885 | :meth:`~.SessionEvents.after_begin` |
| 1886 | |
| 1887 | :meth:`~.SessionEvents.after_transaction_create` |
| 1888 | |
| 1889 | :meth:`~.SessionEvents.after_transaction_end` |
| 1890 | |
| 1891 | """ |
| 1892 | |
| 1893 | def after_rollback(self, session: Session) -> None: |
| 1894 | """Execute after a real DBAPI rollback has occurred. |