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

Method add

lib/sqlalchemy/ext/asyncio/session.py:1110–1142  ·  view source on GitHub ↗

r"""Place an object into this :class:`_orm.Session`. .. container:: class_bases Proxied for the :class:`_orm.Session` class on behalf of the :class:`_asyncio.AsyncSession` class. Objects that are in the :term:`transient` state when passed to the :me

(self, instance: object, _warn: bool = True)

Source from the content-addressed store, hash-verified

1108 return self._proxied.__iter__()
1109
1110 def add(self, instance: object, _warn: bool = True) -> None:
1111 r"""Place an object into this :class:`_orm.Session`.
1112
1113 .. container:: class_bases
1114
1115 Proxied for the :class:`_orm.Session` class on
1116 behalf of the :class:`_asyncio.AsyncSession` class.
1117
1118 Objects that are in the :term:`transient` state when passed to the
1119 :meth:`_orm.Session.add` method will move to the
1120 :term:`pending` state, until the next flush, at which point they
1121 will move to the :term:`persistent` state.
1122
1123 Objects that are in the :term:`detached` state when passed to the
1124 :meth:`_orm.Session.add` method will move to the :term:`persistent`
1125 state directly.
1126
1127 If the transaction used by the :class:`_orm.Session` is rolled back,
1128 objects which were transient when they were passed to
1129 :meth:`_orm.Session.add` will be moved back to the
1130 :term:`transient` state, and will no longer be present within this
1131 :class:`_orm.Session`.
1132
1133 .. seealso::
1134
1135 :meth:`_orm.Session.add_all`
1136
1137 :ref:`session_adding` - at :ref:`session_basics`
1138
1139
1140 """ # noqa: E501
1141
1142 return self._proxied.add(instance, _warn=_warn)
1143
1144 def add_all(self, instances: Iterable[object]) -> None:
1145 r"""Add the given collection of instances to this :class:`_orm.Session`.

Calls

no outgoing calls