Participer au site avec un Tip
Rechercher
 

Améliorations / Corrections

Vous avez des améliorations (ou des corrections) à proposer pour ce document : je vous remerçie par avance de m'en faire part, cela m'aide à améliorer le site.

Emplacement :

Description des améliorations :

Classe « SessionEvents »

Méthode sqlalchemy.orm.SessionEvents.after_commit

Signature de la méthode after_commit

def after_commit(self, session) 

Description

after_commit.__doc__

Execute after a commit has occurred.

.. container:: event_signatures

     Example argument forms::

        from sqlalchemy import event


        @event.listens_for(SomeSessionOrFactory, 'after_commit')
        def receive_after_commit(session):
            "listen for the 'after_commit' event"

            # ... (event handling logic) ...


.. 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 these events, use the
    :meth:`~.SessionEvents.before_flush`,
    :meth:`~.SessionEvents.after_flush`, or
    :meth:`~.SessionEvents.after_flush_postexec`
    events.

.. note::

    The :class:`.Session` is not in an active transaction
    when the :meth:`~.SessionEvents.after_commit` event is invoked,
    and therefore can not emit SQL.  To emit SQL corresponding to
    every transaction, use the :meth:`~.SessionEvents.before_commit`
    event.

:param session: The target :class:`.Session`.

.. seealso::

    :meth:`~.SessionEvents.before_commit`

    :meth:`~.SessionEvents.after_begin`

    :meth:`~.SessionEvents.after_transaction_create`

    :meth:`~.SessionEvents.after_transaction_end`