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 :

Vous êtes un professionnel et vous avez besoin d'une formation ? Programmation Python
Les compléments
Voir le programme détaillé
Classe « scoped_session »

Méthode sqlalchemy.orm.scoped_session.close

Signature de la méthode close

def close(self) -> 'None' 

Description

help(scoped_session.close)

Close out the transactional resources and ORM objects used by this
:class:`_orm.Session`.

.. container:: class_bases

    Proxied for the :class:`_orm.Session` class on
    behalf of the :class:`_orm.scoping.scoped_session` class.

This expunges all ORM objects associated with this
:class:`_orm.Session`, ends any transaction in progress and
:term:`releases` any :class:`_engine.Connection` objects which this
:class:`_orm.Session` itself has checked out from associated
:class:`_engine.Engine` objects. The operation then leaves the
:class:`_orm.Session` in a state which it may be used again.

.. tip::

    In the default running mode the :meth:`_orm.Session.close`
    method **does not prevent the Session from being used again**.
    The :class:`_orm.Session` itself does not actually have a
    distinct "closed" state; it merely means
    the :class:`_orm.Session` will release all database connections
    and ORM objects.

    Setting the parameter :paramref:`_orm.Session.close_resets_only`
    to ``False`` will instead make the ``close`` final, meaning that
    any further action on the session will be forbidden.

.. versionchanged:: 1.4  The :meth:`.Session.close` method does not
   immediately create a new :class:`.SessionTransaction` object;
   instead, the new :class:`.SessionTransaction` is created only if
   the :class:`.Session` is used again for a database operation.

.. seealso::

    :ref:`session_closing` - detail on the semantics of
    :meth:`_orm.Session.close` and :meth:`_orm.Session.reset`.

    :meth:`_orm.Session.reset` - a similar method that behaves like
    ``close()`` with  the parameter
    :paramref:`_orm.Session.close_resets_only` set to ``True``.




Vous êtes un professionnel et vous avez besoin d'une formation ? Programmation Python
Les compléments
Voir le programme détaillé