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

Method __call__

lib/sqlalchemy/orm/session.py:5127–5145  ·  view source on GitHub ↗

Produce a new :class:`.Session` object using the configuration established in this :class:`.sessionmaker`. In Python, the ``__call__`` method is invoked on an object when it is "called" in the same way as a function:: Session = sessionmaker(some_engine)

(self, **local_kw: Any)

Source from the content-addressed store, hash-verified

5125 return session._maker_context_manager()
5126
5127 def __call__(self, **local_kw: Any) -> _S:
5128 """Produce a new :class:`.Session` object using the configuration
5129 established in this :class:`.sessionmaker`.
5130
5131 In Python, the ``__call__`` method is invoked on an object when
5132 it is "called" in the same way as a function::
5133
5134 Session = sessionmaker(some_engine)
5135 session = Session() # invokes sessionmaker.__call__()
5136
5137 """
5138 for k, v in self.kw.items():
5139 if k == "info" and "info" in local_kw:
5140 d = v.copy()
5141 d.update(local_kw["info"])
5142 local_kw["info"] = d
5143 else:
5144 local_kw.setdefault(k, v)
5145 return self.class_(**local_kw)
5146
5147 def configure(self, **new_kw: Any) -> None:
5148 """(Re)configure the arguments for this sessionmaker.

Callers

nothing calls this directly

Calls 5

class_Method · 0.80
itemsMethod · 0.45
copyMethod · 0.45
updateMethod · 0.45
setdefaultMethod · 0.45

Tested by

no test coverage detected