MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / before_attach

Method before_attach

lib/sqlalchemy/orm/events.py:2045–2057  ·  view source on GitHub ↗

Execute before an instance is attached to a session. This is called before an add, delete or merge causes the object to be part of the session. .. seealso:: :meth:`~.SessionEvents.after_attach` :ref:`session_lifecycle_events`

(self, session: Session, instance: _O)

Source from the content-addressed store, hash-verified

2043
2044 @_lifecycle_event
2045 def before_attach(self, session: Session, instance: _O) -> None:
2046 """Execute before an instance is attached to a session.
2047
2048 This is called before an add, delete or merge causes
2049 the object to be part of the session.
2050
2051 .. seealso::
2052
2053 :meth:`~.SessionEvents.after_attach`
2054
2055 :ref:`session_lifecycle_events`
2056
2057 """
2058
2059 @_lifecycle_event
2060 def after_attach(self, session: Session, instance: _O) -> None:

Callers 1

_before_attachMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected