MCPcopy Create free account
hub / github.com/sqlalchemy/sqlalchemy / before_attach

Method before_attach

lib/sqlalchemy/orm/events.py:2056–2068  ·  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

2054
2055 @_lifecycle_event
2056 def before_attach(self, session: Session, instance: _O) -> None:
2057 """Execute before an instance is attached to a session.
2058
2059 This is called before an add, delete or merge causes
2060 the object to be part of the session.
2061
2062 .. seealso::
2063
2064 :meth:`~.SessionEvents.after_attach`
2065
2066 :ref:`session_lifecycle_events`
2067
2068 """
2069
2070 @_lifecycle_event
2071 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