Library

A wide array of documentation both official and non-official exists for SQLAlchemy. The following is a guide to the some of the best information available.

Reference Documentation

The SQLAlchemy Reference Documentation is by far the most important place for both the newest user and the veteran alchemist. The Reference Documentation represents an ongoing effort that rivals that of the SQLAlchemy project itself, and is constantly evolving to be ever more complete and navigable. The newest versions of the documentation will be the most up-to-date and accurate; features and behaviors that were only introduced in more recent versions should always be noted.

Architectural Documentation

A SQLAlchemy chapter was written for the book The Architecture of Open Source Applications in 2011. This chapter includes an in-depth introduction to the key concepts behind both the Core and ORM components of SQLAlchemy:

Blog Posts

A series of blog posts by Mike Bayer.

Talks

A wide variety of talks both by SQLAlchemy creators and users have been presented at many conferences worldwide. Here's only a choice few of them:

  • Building the App - presented at Pycon North America, 2014

    Author: Mike Bayer

    In this talk we'll illustrate a simple web application using SQLAlchemy, showing off the style of development that SQLAlchemy is most geared towards, the so-called "foundational" style which provides for development and maintainance of custom conventions which then service the needs of the model declarations and use case implementations.

  • Introduction to SQLAlchemy Core - presented at Pycon North America, 2014

    Author: Jason Meyers

    This talk provides a broad-based introduction to SQLAlchemy Core library. It is focused on someone new to SQLAlchemy Core, who has experience with other database technologies such as Django or SQLAlchemy ORM. We'll cover the differences between the domain-centric models of those tools compared to the schema-centric model and how we can use that to deal with common and unusual data sources.

  • Sane Schema Migrations with Alembic and SQLAlchemy - presented at Pycon North America, 2014

    Author: Selena Deckelmann

    Working with developers on schema migrations is a perennial challenge for DBAs and developers. Devs tend to like a "set it and forget it" tool. This talk discusses the strategies used to move from a pure SQL and shell migration system to using SQLAlchemy and Alembic for maximum DBA and developer happiness.

  • Flexing SQLAlchemy's Relational Power - presented at Pycon US, 2012

    Author: Brandon Rhodes

    Too often, programmers use ORMs to hide from their database and avoid learning how it works. Instead, I encourage programmers to learn a bit of SQL and become familiar with the problems that database queries are designed to solve well. In this talk, I outline the basics of using SQLAlchemy to craft efficient queries and avoid several common database query anti-patterns.

  • The SQLAlchemy Session - In Depth - presented at Pycon Canada, 2012

    Author: Mike Bayer

    This talk describes why SQLAlchemy has always been called a "toolkit", detailing the software construction mindset for which SQLAlchemy was designed to be used with. The talk refers to this as the "Hand Coded" approach, and has an emphasis on user-created patterns and conventions, along with explicit exposure of relational structures.

  • Hand Coded Applications with SQLAlchemy - presented at Pycon US, 2012

    Author: Mike Bayer

    This talk describes why SQLAlchemy has always been called a "toolkit", detailing the software construction mindset for which SQLAlchemy was designed to be used with. The talk refers to this as the "Hand Coded" approach, and has an emphasis on user-created patterns and conventions, along with explicit exposure of relational structures.

  • SQLAlchemy - an Architectural Retrospective - presented at PyGotham 2011

    Author: Mike Bayer

    This talk walks through some highlights of SQLAlchemy internal design and methodology, based on the (now published) chapter for the "Architecture of Open Source Applications" book. We'll have a little bit of SQLAlchemy philosophy, an overview of the Core, and then a 500-ft view of how the ORM goes about things, with plenty of cool looking diagrams.

Tutorials

The most up-to-date and complete tutorials available for getting started with SQLAlchemy are the Core and ORM tutorials included with SQLAlchemy's own documentation. There's a few other good resources available as well:

  • Introduction to SQLAlchemy - presented at many Pycon and other conferences

    Author: Mike Bayer

    This is Mike Bayer's own "getting started" tutorial that presents a fast paced but beginner-focused tutorial on what SQLAlchemy is all about. While the tutorial has evolved over the years and at this point is fairly fixed. The "Prerequisite Material" is highly recommended and includes a PDF introductory guide as well as a self-installing, runnable code demo that's used in the tutorial.

  • Python SQLAlchemy Tutorial - on the Python Central website

    Author: Xiaonuo Gantan

    A series of beginner-focused SQLAlchemy tutorials covering a wide range of basic topics. While a lot of the information here is derived from the main documentation, the pace is slower and there are also details culled from other sources, including performance tips, comparison to other ORMs, and design philosophies. A very good effort by author Xiaonuo Gantan.

  • SQLAlchemy + URL Dispatch Wiki Tutorial - Part of the Pylons Documentation

    Author: Chris McDonough

    This is the official tutorial for SQLAlchemy integration within the Pyramid Web Framework. The basic steps to integrate SQLAlchemy within a traditional web application are laid out here and are mostly in conformance with those guidelines referenced by SQLAlchemy's documentation.

Recipes

SQLAlchemy is a recipe-focused library; while it includes a tremendous number of features, overall the emphasis is on that of creating a composable toolkit, so that users can build their own database interaction layers that suit them best. To help with this task, there's a huge number of "recipes", code examples geared towards specific use cases. These are currently split out among the SQLAlchemy reference documentation and the wiki: