Introduction to SQLAlchemy

Presenters

Jonathan Ellis and Michael Bayer

Audience

Python experience: intermediate. You should already have some hands-on experience with Python and be comfortable reading modern Python code.

SQL experience: beginning. You should know how to SELECT, INSERT, and DELETE, and how to read queries involving JOINs, but we will only be reading the SQL generated by SA, not writing our own.

ORM experience: prior experience with an object-relational mapper is not necessary.

Requirements

Python 2.4 and a recent 0.4 version of SQLAlchemy (examples are tested with 0.4.2). SQLAlchemy itself only requires Python 2.3 but this tutorial will make use of some more recent Python features like generator expressions.

Summary

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 teaches SQLAlchemy's object-relational mapping to automate painlessly loading and persisting objects from and to your database, even when complex relationships exist.

Detailed Outline

  • Introduction
    • Philosophy
    • SQLAlchemy features
  • Fundamentals
    • Introduction to object-relational mapping
    • Data Mapper pattern vs Active Record
    • Tables
    • Mapping basics
  • Queries
    • Conditions, operators
    • Joins
    • Lazy and eager loading
  • Sessions & identity map
    • detaching, attaching objects
    • Lifecycle relations
  • More Mapping
    • one to one, many to many
    • back references
  • Extensions
    • SqlSoup
    • Elixir

Presenter Bios

Jonathan Ellis recently left Mozy, Inc., where he wrote a storage system similar to Amazon S3 to store petabytes of backup data. He is the author of the SqlSoup extension to SQLAlchemy. Jonathan lives in Utah with his wife and two children.

Michael Bayer is a NYC-based software contractor with a decade of experience dealing with relational databases of all shapes and sizes. After writing many homegrown database abstraction layers in such languages as C, Java and Perl, and finally after several years of practice working with a huge multi-server Oracle system for Major League Baseball, he wrote SQLAlchemy as the 'ultimate toolset' for generating SQL and dealing with databases overall. The goal is to contribute towards a world-class one-of-a-kind toolset for Python, helping to make Python the universally popular programming platform it deserves to be.

Diamond

  • Google - Diamond
  • White Oak Technologies - Diamond

Platinum

  • Zenoss - Platinum
  • Enthought - Platinum
  • Microsoft Port 25 - Platinum
  • Sun Microsystems - Platinum

Gold

  • Wingware - Gold
  • Resolver Systems - Gold
  • ITA Software - Gold
  • Leapfrog Online - Gold
  • Predictix - Gold
  • Accense Technology, Inc. - Gold
  • IronPort - Gold

Silver

  • Imaginary Landscape - Silver
  • Tummy.com - Silver
  • Activestate - Silver
  • PSC Consulting - Silver
  • Canonical - Silver
  • ZeOmega - Silver
  • Symbian Press-Forum Nokia - Silver
  • Nuance Communications - Silver
  • CCP Games - Silver
  • Fivedash.com - Silver
  • Rackspace - Silver
  • Quality Vision International - Silver

Vendor II

  • O'Reilly - Vendor II
  • Pearson Publishing - Vendor II