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.before_commit

Signature de la méthode before_commit

def before_commit(self, session) 

Description

before_commit.__doc__

Execute before commit is called.

.. container:: event_signatures

     Example argument forms::

        from sqlalchemy import event


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

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


.. note::

    The :meth:`~.SessionEvents.before_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.

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

.. seealso::

    :meth:`~.SessionEvents.after_commit`

    :meth:`~.SessionEvents.after_begin`

    :meth:`~.SessionEvents.after_transaction_create`

    :meth:`~.SessionEvents.after_transaction_end`