PyCon 2010:Advanced SQL Alchemy
Presented by Michael Bayer
SQLAlchemy is the premier SQL toolkit for Python. SQLAlchemy exposes the full power of SQL while remaining easy to use for the basics, and is flexible enough to work with existing database schemas as well as fresh designs. SQLAlchemy is used in production by leading Python web frameworks Pylons and TurboGears as well as many other web and non-web developers.
This tutorial discusses current data mapping techniques, advanced Query techniques, Session/transaction usage, and maximizing schema usage with SQLAlchemy's event model.
Python experience: intermediate. You should already have some hands-on experience with Python and be comfortable reading modern Python code.
SQL experience: intermediate. We will use subselects and outer joins as part of the SQL layer.
ORM experience: prior experience with SQLAlchemy is recommended.
- Initial configuration
- Basic mapping
- Building a many-to-many relation
- Using late-evaluated configuration arguments
- Selecting objects, selecting columns
- Thinking generatively
- Joining like a Pro
- Power Eager Loading
- Selecting from Anything
- Transaction lifecycle
- Scoping objects in and out of caches using merge()
- Single Table Inheritance
- Joined Table Inheritance
- High Level/Low Level Joined Queries
- Creating new SQL constructs
- Creating new DDL constructs
Extending the ORM
- Using SessionExtension to populate denormalized views
- Subclassing Query to Suit Your Needs