SQLAlchemy
The Database Toolkit for Python
The Database Toolkit for Python
  • home
  • features
    • Philosophy Statement
    • Feature Overview
    • Testimonials
  • news
  • documentation
    • Current Documentation (version 2.0)

    • Documentation by Version
    • Version 2.1 (development)
    • Version 2.0
    • Version 1.4
    • Version 1.3

    • Talks and Tutorials
    • Published content overview
  • community
    • Get Support
    • Participate
    • Develop
    • Code of Conduct
    • Github
  • download
    • Download
    • Current Release Series (2.0)
    • Maintenance Release (1.4)
    • Development Access
    • License
    • Version Numbering
    • Release Status
Release: 1.4.54 legacy version | Release Date: September 5, 2024

SQLAlchemy 1.4 Documentation

SQLAlchemy 1.4 Documentation

legacy version

Home | Download this Documentation

SQLAlchemy ORM

  • ORM Quick Start
  • Object Relational Tutorial (1.x API)
  • ORM Mapped Class Configuration
    • ORM Mapped Class Overview
    • Mapping Classes with Declarative¶
      • Declarative Mapping Styles
      • Table Configuration with Declarative
      • Mapper Configuration with Declarative
      • Composing Mapped Hierarchies with Mixins
    • Integration with dataclasses and attrs
    • Mapping Columns and Expressions
    • 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

Project Versions

  • 1.4.54

Home | Download this Documentation

  • Previous: ORM Mapped Class Overview
  • Next: Declarative Mapping Styles
  • Up: Home
    • SQLAlchemy ORM
      • ORM Mapped Class Configuration
  • On this page:
    • Mapping Classes with Declarative

Mapping Classes with Declarative¶

The Declarative mapping style is the primary style of mapping that is used with SQLAlchemy. See the section Declarative Mapping for the top level introduction.

  • Declarative Mapping Styles
    • Using a Generated Base Class
    • Creating an Explicit Base Non-Dynamically (for use with mypy, similar)
    • Declarative Mapping using a Decorator (no declarative base)
  • Table Configuration with Declarative
    • Declarative Table
      • Accessing Table and Metadata
      • Declarative Table Configuration
      • Explicit Schema Name with Declarative Table
      • Appending additional columns to an existing Declarative mapped class
    • Declarative with Imperative Table (a.k.a. Hybrid Declarative)
    • Mapping Declaratively with Reflected Tables
      • Using DeferredReflection
      • Using Automap
  • Mapper Configuration with Declarative
    • Defining Mapped Properties with Declarative
    • Mapper Configuration Options with Declarative
      • Constructing mapper arguments dynamically
    • Other Declarative Mapping Directives
      • __declare_last__()
      • __declare_first__()
      • metadata
      • __abstract__
      • __table_cls__
  • Composing Mapped Hierarchies with Mixins
    • Augmenting the Base
    • Mixing in Columns
    • Mixing in Relationships
      • Using Advanced Relationship Arguments (e.g. primaryjoin, etc.)
    • Mixing in deferred(), column_property(), and other MapperProperty classes
    • Controlling table inheritance with mixins
    • Mixing in Columns in Inheritance Scenarios
    • Combining Table/Mapper Arguments from Multiple Mixins
    • Creating Indexes with Mixins
Previous: ORM Mapped Class Overview Next: Declarative Mapping Styles
© Copyright 2007-2025, 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: Mon 05 May 2025 04:18:07 PM EDT
Python

Website content copyright © by SQLAlchemy authors and contributors. SQLAlchemy and its documentation are licensed under the MIT license.

SQLAlchemy is a trademark of Michael Bayer. mike(&)zzzcomputing.com All rights reserved.

Website generation by zeekofile, with huge thanks to the Blogofile project.

Mastodon Mastodon