Change the future

Thursday 1:20 p.m.–4:40 p.m.

Introduction to SQLAlchemy

Mike Bayer

Audience level:
Intermediate
Category:
Databases/NoSQL

Description

The goal of the tutorial is a broad-based introduction to SQLAlchemy, spanning the Core and ORM components as well as the systems that underlie them. The tutorial takes the "harder" approach teaching from fundamentals first, emphasizing details on how the library interacts with the database and SQL and concluding with an introduction to the ORM, providing a solid perspective for continued study.

Abstract

In contrast to ORM tutorials which might begin with applied object-relational examples, this tutorial takes the opposite approach of building up from underlying and core components first, moving first through relational database concepts into the Python DBAPI, then describing the SQLAlchemy Core, the SQL Expression Language, and finally the ORM.

In terms of learning SQLAlchemy, this is the harder road to travel, and at the end the ORM component itself will only have been roughly introduced. However, the goal is so that new users would leave with a solid grasp on what exactly SQLAlchemy is doing and how it's doing it, so that their future endeavors in continuing to learn about ORMs, SQLAlchemy or not, is informed by a rough understanding of the underlying fundmantals of interacting with a database.

The outline here may change a bit, as the tutorial barely fit into three hours when I did it last time, and I will likely have to thin out some areas so that there's time for breaks and questions.

  • Introduction to SQLAlchemy

  • Installing Tutorial Scripts

  • Relational Database Review

    • What do we mean "relational"?

    • Tables, columns

    • SQL Syntax

    • Foreign Keys

    • Joins

    • ACID model

  • SQLAlchemy - Overview

    • Goals

    • Philosophies

    • Library Structure

    • Core

    • ORM

    • The four "levels"

  • Level One - Engine, Connection, Transactions

    • Python DBAPI

    • Engine walkthroguh

    • Exercises

  • Level Two - Database Metadata

    • What is Metadata?

    • Metadata / Table walkthrough

    • Types

    • CREATE / DROP

    • Constraints

    • Reflecting DDL

    • Exercises

  • Break

  • Level Three - SQL Expressions

    • Intro

    • Expressions Walkthrough

    • Exercises

  • Level Four - Object Relational Mapping

    • What does an ORM Do ?

    • Flavors of ORM

    • SQLAlchemy ORM

    • Key ORM Patterns

    • ORM Walkthrough

    • Exercises

Update: See updated tutorial preparation instructions at Introduction to SQLAlchemy - reading and software requirements!