ORM Mapped Class Configuration¶
Detailed reference for ORM configuration, not including relationships, which are detailed at Relationship Configuration.
For a quick look at a typical ORM configuration, start with ORM Quick Start.
For an introduction to the concept of object relational mapping as implemented in SQLAlchemy, it’s first introduced in the SQLAlchemy Unified Tutorial at Using ORM Declarative Forms to Define Table Metadata.
- ORM Mapped Class Overview
- Mapping Classes with Declarative
- Declarative Mapping Styles
- Table Configuration with Declarative
- Declarative Table with
mapped_column()- ORM Annotated Declarative - Automated Mapping with Type Annotations
- Dataclass features in
mapped_column() - Accessing Table and Metadata
- Declarative Table Configuration
- Explicit Schema Name with Declarative Table
- Setting Load and Persistence Options for Declarative Mapped Columns
- Naming Declarative Mapped Columns Explicitly
- Appending additional columns to an existing Declarative mapped class
- ORM Annotated Declarative - Complete Guide
mapped_column()derives the datatype and nullability from theMappedannotation- Customizing the Type Map
- Union types inside the Type Map
- Support for Type Alias Types (defined by PEP 695) and NewType
- Mapping Multiple Type Configurations to Python Types
- Mapping Whole Column Declarations to Python Types
- Using Python
Enumor pep-586Literaltypes in the type map
- Declarative with Imperative Table (a.k.a. Hybrid Declarative)
- Mapping Declaratively with Reflected Tables
- Declarative Table with
- Mapper Configuration with Declarative
- Composing Mapped Hierarchies with Mixins
- Augmenting the Base
- Mixing in Columns
- Mixing in Relationships
- Mixing in
_orm.column_property()and other_orm.MapperPropertyclasses - Using Mixins and Base Classes with Mapped Inheritance Patterns
- Combining Table/Mapper Arguments from Multiple Mixins
- Creating Indexes and Constraints with Naming Conventions on Mixins
- Integration with dataclasses and attrs
- SQL Expressions as Mapped Attributes
- Changing Attribute Behavior
- Composite Column Types
- Mapping Class Inheritance Hierarchies
- Non-Traditional Mappings
- Configuring a Version Counter
- Class Mapping API
registryadd_mapped_attribute()column_property()declarative_base()declarative_mixin()as_declarative()mapped_column()declared_attrDeclarativeBaseDeclarativeBaseNoMetahas_inherited_table()synonym_for()object_mapper()class_mapper()configure_mappers()clear_mappers()identity_key()polymorphic_union()orm_insert_sentinel()reconstructor()MapperMapper.__init__()Mapper.add_properties()Mapper.add_property()Mapper.all_orm_descriptorsMapper.attrsMapper.base_mapperMapper.cMapper.cascade_iterator()Mapper.class_Mapper.class_managerMapper.column_attrsMapper.columnsMapper.common_parent()Mapper.compositesMapper.concreteMapper.configuredMapper.entityMapper.get_property()Mapper.get_property_by_column()Mapper.identity_key_from_instance()Mapper.identity_key_from_primary_key()Mapper.identity_key_from_row()Mapper.inheritsMapper.is_mapperMapper.is_sibling()Mapper.isa()Mapper.iterate_propertiesMapper.local_tableMapper.mapped_tableMapper.mapperMapper.non_primaryMapper.persist_selectableMapper.polymorphic_identityMapper.polymorphic_iterator()Mapper.polymorphic_mapMapper.polymorphic_onMapper.primary_keyMapper.primary_key_from_instance()Mapper.primary_mapper()Mapper.relationshipsMapper.selectableMapper.self_and_descendantsMapper.singleMapper.synonymsMapper.tablesMapper.validatorsMapper.with_polymorphic_mappers
MappedAsDataclassMappedClassProtocol