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

Method map_imperatively

lib/sqlalchemy/orm/decl_api.py:1827–1883  ·  view source on GitHub ↗

r"""Map a class imperatively. In this form of mapping, the class is not scanned for any mapping information. Instead, all mapping constructs are passed as arguments. This method is intended to be fully equivalent to the now-removed SQLAlchemy ``mapper()`` f

(
        self,
        class_: Type[_O],
        local_table: Optional[FromClause] = None,
        **kw: Any,
    )

Source from the content-addressed store, hash-verified

1825 return cls.__mapper__ # type: ignore
1826
1827 def map_imperatively(
1828 self,
1829 class_: Type[_O],
1830 local_table: Optional[FromClause] = None,
1831 **kw: Any,
1832 ) -> Mapper[_O]:
1833 r"""Map a class imperatively.
1834
1835 In this form of mapping, the class is not scanned for any mapping
1836 information. Instead, all mapping constructs are passed as
1837 arguments.
1838
1839 This method is intended to be fully equivalent to the now-removed
1840 SQLAlchemy ``mapper()`` function, except that it's in terms of
1841 a particular registry.
1842
1843 E.g.::
1844
1845 from sqlalchemy.orm import registry
1846
1847 mapper_registry = registry()
1848
1849 my_table = Table(
1850 "my_table",
1851 mapper_registry.metadata,
1852 Column("id", Integer, primary_key=True),
1853 )
1854
1855
1856 class MyClass:
1857 pass
1858
1859
1860 mapper_registry.map_imperatively(MyClass, my_table)
1861
1862 See the section :ref:`orm_imperative_mapping` for complete background
1863 and usage examples.
1864
1865 :param class\_: The class to be mapped. Corresponds to the
1866 :paramref:`_orm.Mapper.class_` parameter.
1867
1868 :param local_table: the :class:`_schema.Table` or other
1869 :class:`_sql.FromClause` object that is the subject of the mapping.
1870 Corresponds to the
1871 :paramref:`_orm.Mapper.local_table` parameter.
1872
1873 :param \**kw: all other keyword arguments are passed to the
1874 :class:`_orm.Mapper` constructor directly.
1875
1876 .. seealso::
1877
1878 :ref:`orm_imperative_mapping`
1879
1880 :ref:`orm_declarative_mapping`
1881
1882 """
1883 return _mapper(self, class_, local_table, kw)
1884

Callers 15

setup_mappersMethod · 0.80
test_unregisterMethod · 0.80
setup_mappersMethod · 0.80
setup_mappersMethod · 0.80
setup_mappersMethod · 0.80
setup_mappersMethod · 0.80
setup_mappersMethod · 0.80
setup_mappersMethod · 0.80
setup_mappersMethod · 0.80
setup_mappersMethod · 0.80
setup_mappersMethod · 0.80

Calls 1

_mapperFunction · 0.85

Tested by 15

setup_mappersMethod · 0.64
test_unregisterMethod · 0.64
setup_mappersMethod · 0.64
setup_mappersMethod · 0.64
setup_mappersMethod · 0.64
setup_mappersMethod · 0.64
setup_mappersMethod · 0.64
setup_mappersMethod · 0.64
setup_mappersMethod · 0.64
setup_mappersMethod · 0.64
setup_mappersMethod · 0.64