Release: 1.4.50 | Release Date: October 29, 2023

SQLAlchemy 1.4 Documentation

SQLAlchemy 1.4 Documentation

Home

SQLAlchemy ORM

  • ORM Quick Start
  • Object Relational Tutorial (1.x API)
  • ORM Mapped Class Configuration
    • ORM Mapped Class Overview
    • Mapping Classes with Declarative
    • Integration with dataclasses and attrs
    • Mapping Columns and Expressions¶
      • Mapping Table Columns
      • 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
  • Relationship Configuration
  • Querying Data, Loading Objects
  • Using the Session
  • Events and Internals
  • ORM Extensions
  • ORM Examples

Home

  • Previous: Integration with dataclasses and attrs
  • Next: Mapping Table Columns
  • Up: Home
    • SQLAlchemy ORM
      • ORM Mapped Class Configuration
  • On this page:
    • Mapping Columns and Expressions

Mapping Columns and Expressions¶

The following sections discuss how table columns and SQL expressions are mapped to individual object attributes.

  • Mapping Table Columns
    • Naming Columns Distinctly from Attribute Names
    • Automating Column Naming Schemes from Reflected Tables
    • Using column_property for column level options
      • column_property()
    • Mapping to an Explicit Set of Primary Key Columns
    • Mapping a Subset of Table Columns
  • SQL Expressions as Mapped Attributes
    • Using a Hybrid
    • Using column_property
      • Composing from Column Properties at Mapping Time
    • Using a plain descriptor
    • Query-time SQL expressions as mapped attributes
      • Using with_expression() with UNIONs, other subqueries
  • Changing Attribute Behavior
    • Simple Validators
      • validates()
    • Using Custom Datatypes at the Core Level
    • Using Descriptors and Hybrids
    • Synonyms
      • synonym()
    • Operator Customization
  • Composite Column Types
    • composite()
    • Tracking In-Place Mutations on Composites
    • Redefining Comparison Operations for Composites
    • Nesting Composites
Previous: Integration with dataclasses and attrs Next: Mapping Table Columns
© Copyright 2007-2023, the SQLAlchemy authors and contributors.

flambé! the dragon and The Alchemist image designs created and generously donated by Rotem Yaari.

Created using Sphinx 7.2.6. Documentation last generated: Tue 19 Dec 2023 06:44:08 PM