Flush pending changes and commit the current transaction. When the COMMIT operation is complete, all objects are fully :term:`expired`, erasing their internal contents, which will be automatically re-loaded when the objects are next accessed. In the interim, these ob
(self)
| 2038 | self._transaction.rollback(_to_root=True) |
| 2039 | |
| 2040 | def commit(self) -> None: |
| 2041 | class="st">"""Flush pending changes and commit the current transaction. |
| 2042 | |
| 2043 | When the COMMIT operation is complete, all objects are fully |
| 2044 | :term:`expired`, erasing their internal contents, which will be |
| 2045 | automatically re-loaded when the objects are next accessed. In the |
| 2046 | interim, these objects are in an expired state and will not function if |
| 2047 | they are :term:`detached` from the :class:`.Session`. Additionally, |
| 2048 | this re-load operation is not supported when using asyncio-oriented |
| 2049 | APIs. The :paramref:`.Session.expire_on_commit` parameter may be used |
| 2050 | to disable this behavior. |
| 2051 | |
| 2052 | When there is no transaction in place for the :class:`.Session`, |
| 2053 | indicating that no operations were invoked on this :class:`.Session` |
| 2054 | since the previous call to :meth:`.Session.commit`, the method will |
| 2055 | begin and commit an internal-only class="st">"logical" transaction, that does not |
| 2056 | normally affect the database unless pending flush changes were |
| 2057 | detected, but will still invoke event handlers and object expiration |
| 2058 | rules. |
| 2059 | |
| 2060 | The outermost database transaction is committed unconditionally, |
| 2061 | automatically releasing any SAVEPOINTs in effect. |
| 2062 | |
| 2063 | .. seealso:: |
| 2064 | |
| 2065 | :ref:`session_committing` |
| 2066 | |
| 2067 | :ref:`unitofwork_transaction` |
| 2068 | |
| 2069 | :ref:`asyncio_orm_avoid_lazyloads` |
| 2070 | |
| 2071 | class="st">""" |
| 2072 | trans = self._transaction |
| 2073 | if trans is None: |
| 2074 | trans = self._autobegin_t() |
| 2075 | |
| 2076 | trans.commit(_to_root=True) |
| 2077 | |
| 2078 | def prepare(self) -> None: |
| 2079 | class="st">"""Prepare the current transaction in progress for two phase commit. |