MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / reset

Method reset

lib/sqlalchemy/orm/session.py:2625–2648  ·  view source on GitHub ↗

Close out the transactional resources and ORM objects used by this :class:`_orm.Session`, resetting the session to its initial state. This method provides for same "reset-only" behavior that the :meth:`_orm.Session.close` method has provided historically, where the s

(self)

Source from the content-addressed store, hash-verified

2623 self._close_impl(invalidate=False)
2624
2625 def reset(self) -> None:
2626 """Close out the transactional resources and ORM objects used by this
2627 :class:`_orm.Session`, resetting the session to its initial state.
2628
2629 This method provides for same "reset-only" behavior that the
2630 :meth:`_orm.Session.close` method has provided historically, where the
2631 state of the :class:`_orm.Session` is reset as though the object were
2632 brand new, and ready to be used again.
2633 This method may then be useful for :class:`_orm.Session` objects
2634 which set :paramref:`_orm.Session.close_resets_only` to ``False``,
2635 so that "reset only" behavior is still available.
2636
2637 .. versionadded:: 2.0.22
2638
2639 .. seealso::
2640
2641 :ref:`session_closing` - detail on the semantics of
2642 :meth:`_orm.Session.close` and :meth:`_orm.Session.reset`.
2643
2644 :meth:`_orm.Session.close` - a similar method will additionally
2645 prevent reuse of the Session when the parameter
2646 :paramref:`_orm.Session.close_resets_only` is set to ``False``.
2647 """
2648 self._close_impl(invalidate=False, is_reset=True)
2649
2650 def invalidate(self) -> None:
2651 """Close this Session, using connection invalidation.

Callers 1

addMethod · 0.45

Calls 1

_close_implMethod · 0.95

Tested by

no test coverage detected