Contribute Media
A thank you to everyone who makes this possible: Read More

PyCon 2010:Advanced SQL Alchemy

Description

Advanced SQLAlchemy

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.

Intended Audience

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.

Class Outline

Declarative Mapping

  • Initial configuration
  • Basic mapping
  • Building a many-to-many relation
  • Using late-evaluated configuration arguments

Advanced queries

  • Selecting objects, selecting columns
  • Thinking generatively
  • Joining like a Pro
  • Power Eager Loading
  • Selecting from Anything

Session Techniques

  • Transaction lifecycle
  • Scoping objects in and out of caches using merge()

Inheritance Mapping

  • Single Table Inheritance
  • Joined Table Inheritance
  • High Level/Low Level Joined Queries

Extending SQL

  • Creating new SQL constructs
  • Creating new DDL constructs

Extending the ORM

  • Using SessionExtension to populate denormalized views
  • Subclassing Query to Suit Your Needs

Details

Improve this page