Class decorator that will apply the Declarative mapping process to a given class. E.g.:: from sqlalchemy.orm import registry mapper_registry = registry() @mapper_registry.mapped class Foo: __tablename__ = "some_tabl
(self, cls: Type[_O])
| 1697 | return decorate |
| 1698 | |
| 1699 | def mapped(self, cls: Type[_O]) -> Type[_O]: |
| 1700 | """Class decorator that will apply the Declarative mapping process |
| 1701 | to a given class. |
| 1702 | |
| 1703 | E.g.:: |
| 1704 | |
| 1705 | from sqlalchemy.orm import registry |
| 1706 | |
| 1707 | mapper_registry = registry() |
| 1708 | |
| 1709 | |
| 1710 | @mapper_registry.mapped |
| 1711 | class Foo: |
| 1712 | __tablename__ = "some_table" |
| 1713 | |
| 1714 | id = Column(Integer, primary_key=True) |
| 1715 | name = Column(String) |
| 1716 | |
| 1717 | See the section :ref:`orm_declarative_mapping` for complete |
| 1718 | details and examples. |
| 1719 | |
| 1720 | :param cls: class to be mapped. |
| 1721 | |
| 1722 | :return: the class that was passed. |
| 1723 | |
| 1724 | .. seealso:: |
| 1725 | |
| 1726 | :ref:`orm_declarative_mapping` |
| 1727 | |
| 1728 | :meth:`_orm.registry.generate_base` - generates a base class |
| 1729 | that will apply Declarative mapping to subclasses automatically |
| 1730 | using a Python metaclass. |
| 1731 | |
| 1732 | .. seealso:: |
| 1733 | |
| 1734 | :meth:`_orm.registry.mapped_as_dataclass` |
| 1735 | |
| 1736 | """ |
| 1737 | _as_declarative(self, cls, cls.__dict__) |
| 1738 | return cls |
| 1739 | |
| 1740 | def as_declarative_base(self, **kw: Any) -> Callable[[Type[_T]], Type[_T]]: |
| 1741 | """ |