SQLAlchemy - The Architecture of Open Source Applicaitons

Table of Contents

The Core/ORM Dichotomy

Taming the DBAPI

Schema Definition

SQL Expressions

SELECT id FROM user WHERE name = ?
from sqlalchemy.sql import table, column, select
user = table('user', column('id'), column('name'))
stmt = select([user.c.id]).where(user.c.name=='ed')

Class Mapping with the ORM

user_table = Table("user", metadata,
    Column('id', Integer, primary_key=True),
)

class User(object):
    pass

mapper(User, user_table, properties={
    'related':relationship(Address)
})

Query and Loading Behavior

Session/Identity Map

Link