Essential SQLAlchemy

Mapping Python to Databases

Rick Copeland

Publisher: O'Reilly, 2008, 215 pages

ISBN: 978-0-596-51614-7

Keywords: Python, Databases

Last modified: Aug. 10, 2009, 10:01 p.m.

Now Python developers can easily access relational databases such as Oracle, DB2, and MySQL. Essential SQLAlchemy walks you through simple queries, demonstrates how to create database applications, explains how to connect to multiple databases simultaneously with the same metadata, and more. With this practical guide, you'll learn how the SQLAlchemy open source code library lets you map objects to database tables without substantially changing your existing Python code. You also learn how to:

  • Create custom types to be used in your schema, and discover when to use them
  • Create objects, save them to a session, and flush them to the database;
  • Run queries, updates, and deletes with SQLAlchemy's SQL expression language
  • Build an object mapper and learn why it's different from active record patterns used in other ORMs;
  • Provide a declarative, active record pattern for use with SQLAlchemy using the Elixir extension
  • Use the SQLSoup extension to provide an automatic metadata and object model based on database reflection
  • Use SQLAlchemy to model object oriented inheritance

This book gives you an objective look at SQLAlchemy from a developer's viewpoint rather than from an advocate's description. It's exactly what you need to quickly get up to speed with this code library.

  • Preface
  1. Introduction to SQLAlchemy
    • What Is SQLAlchemy
    • The Object/Relational "Impedance Mismatch"
    • SQLAlchemy Philosophy
    • SQLAlchemy Architecture
  2. Getting Started
    • Installing SQLAlchemy
    • SQLAlchemy Tutorial
  3. Engines and MetaData
    • Engines and Connectables
    • MetaData
  4. SQLAlchemy Type Engines
    • Type System Overview
    • Built-in Types
    • Application-Specific Custom Types
  5. Running Queries and Updates
    • Inserts, Updates, and Deletes
    • Queries
  6. Building an Object Mapper
    • Introduction to ORMs
    • Declaring Object Mappers
    • Declaring Relationships Between Mappers
    • Extending Mappers
    • ORM Partitioning Strategies
  7. Querying and Updating at the ORM Level
    • The SQLAlchemy ORM Session Object
    • Querying at the ORM Level
    • Contextual or Thread-Local Sessions
  8. Inheritance Mapping
    • Overview of Inheritance Mapping
    • Single Table Inheritance Mapping
    • Concrete Table Inheritance Mapping
    • Joined Table Inheritance Mapping
    • Relations and Inheritance
  9. Elixir: A Declarative Extension to SQLAlchemy
    • Introduction to Elixir
    • Installing Elixir
    • Using Elixir
    • Elixir Extensions
  10. SqlSoup: An Automatic Mapper for SQLAlchemy
    • Introduction to SqlSoup
    • Using SqlSoup for ORM-Style Queries and Updates
    • Using SqlSoup for SQL-Level Inserts, Updates, and Deletes
    • When to Use SqlSoup Versus Elixir Versus "Bare" SQLAlchemy
  11. Other SQLAlchemy Extensions
    • Association Proxy
    • Ordering List
    • Deprecated Extensions


Essential SQLAlchemy

Reviewed by Roland Buresund

Disappointing *** (3 out of 10)

Last modified: Aug. 10, 2009, 10:03 p.m.

Well, as this is the only dedicated book (at the moment) to what everybody is calling the best ORM out there, you expect a thorough walk-through and an excellent introduction to the product. It isn't. Let us put that in perspective: I know SQL (since the 80-ties), Python (likewise), I have developed C/S apps as well as Web-apps as well as ERP-applications and parts of Operating Systems, but I still can not get my head around what the author is trying to convey…

There exists better chapters about SQLAlchemy in other books, that blows the contents of this book away.

Sad to say, this is not recommended reading.


There are currently no comments

New Comment


required (not published)