MCPcopy
hub / github.com/sqlalchemy/sqlalchemy / bind_mapper

Method bind_mapper

lib/sqlalchemy/orm/session.py:2735–2763  ·  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

2733 )
2734
2735 def bind_mapper(
2736 self, mapper: _EntityBindKey[_O], bind: _SessionBind
2737 ) -> None:
2738 """Associate a :class:`_orm.Mapper` or arbitrary Python class with a
2739 "bind", e.g. an :class:`_engine.Engine` or
2740 :class:`_engine.Connection`.
2741
2742 The given entity is added to a lookup used by the
2743 :meth:`.Session.get_bind` method.
2744
2745 :param mapper: a :class:`_orm.Mapper` object,
2746 or an instance of a mapped
2747 class, or any Python class that is the base of a set of mapped
2748 classes.
2749
2750 :param bind: an :class:`_engine.Engine` or :class:`_engine.Connection`
2751 object.
2752
2753 .. seealso::
2754
2755 :ref:`session_partitioning`
2756
2757 :paramref:`.Session.binds`
2758
2759 :meth:`.Session.bind_table`
2760
2761
2762 """
2763 self._add_bind(mapper, bind)
2764
2765 def bind_table(self, table: TableClause, bind: _SessionBind) -> None:
2766 """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