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

Method bind_mapper

lib/sqlalchemy/orm/session.py:2641–2669  ·  view source on GitHub ↗

Associate a :class:`_orm.Mapper` or arbitrary Python class with a "bind", e.g. an :class:`_engine.Engine` or :class:`_engine.Connection`. The given entity is added to a lookup used by the :meth:`.Session.get_bind` method. :param mapper: a :class:`_orm.Mapper

(
        self, mapper: _EntityBindKey[_O], bind: _SessionBind
    )

Source from the content-addressed store, hash-verified

2639 )
2640
2641 def bind_mapper(
2642 self, mapper: _EntityBindKey[_O], bind: _SessionBind
2643 ) -> None:
2644 """Associate a :class:`_orm.Mapper` or arbitrary Python class with a
2645 "bind", e.g. an :class:`_engine.Engine` or
2646 :class:`_engine.Connection`.
2647
2648 The given entity is added to a lookup used by the
2649 :meth:`.Session.get_bind` method.
2650
2651 :param mapper: a :class:`_orm.Mapper` object,
2652 or an instance of a mapped
2653 class, or any Python class that is the base of a set of mapped
2654 classes.
2655
2656 :param bind: an :class:`_engine.Engine` or :class:`_engine.Connection`
2657 object.
2658
2659 .. seealso::
2660
2661 :ref:`session_partitioning`
2662
2663 :paramref:`.Session.binds`
2664
2665 :meth:`.Session.bind_table`
2666
2667
2668 """
2669 self._add_bind(mapper, bind)
2670
2671 def bind_table(self, table: TableClause, bind: _SessionBind) -> None:
2672 """Associate a :class:`_schema.Table` with a "bind", e.g. an

Callers 3

test_get_bindMethod · 0.95
test_twophaseMethod · 0.45

Calls 1

_add_bindMethod · 0.95

Tested by 3

test_get_bindMethod · 0.76
test_twophaseMethod · 0.36