Synopses & Reviews
Essential SQLAlchemy introduces a high-level open-source code library that makes it easier for Python programmers to access relational databases such as Oracle, DB2, MySQL, PostgreSQL, and SQLite. SQLAlchemy has become increasingly popular since its release, but it still lacks good offline documentation. This practical book fills the gap, and because a developer wrote it, you get an objective look at SQLAlchemy's tools rather than an advocate's description of all the "cool" features.
SQLAlchemy includes both a database server-independent SQL expression language and an object-relational mapper (ORM) that lets you map "plain old Python objects" (POPOs) to database tables without substantially changing your existing Python code. Essential SQLAlchemy demonstrates how to use the library to create a simple database application, walks you through simple queries, and explains how to use SQLAlchemy to connect to multiple databases simultaneously with the same Metadata. You also learn how to:
- Create custom types to be used in your schema, and when it's useful to use custom rather than built-in types
- Run queries, updates, and deletes with SQLAlchemy's SQL expression language
- Build an object mapper with SQLAlchemy, and understand the differences between this and active record patterns used in other ORMs
- Create objects, save them to a session, and flush them to the database
- Use SQLAlchemy to model object oriented inheritance
- 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
In addition, you'll learn how and when to use other extensions to SQLAlchemy, including AssociationProxy, OrderingList, and more.
Essential SQLAlchemy is the much-needed guide for every Python developer using this code library. Instead of a feature-by-feature documentation, this book takes an "essentials" approach that gives you exactly what you need to become productive with SQLAlchemy right away.
"Essential SQLAlchemy" introduces a high-level open source code library that makes it easier for Python programmers to access relational databases such as Oracle, DB2, MySQL, PostgreSQL, and SQLLite.
About the Author
Rick Copeland is the Principal Consultant and Founder at Arborian Consulting, a business focusing on MongoDB and Python custom development and training. Rick is a frequent speaker at MongoDB events, an avid MongoDB enthusiast, and is a charter member of 10gen's "Masters of MongoDB." In the non-MongoDB side of things, Rick is also a well-known Python developer and member of the Python Software Foundation, having contributed to a number of open-source projects and spoken at various evens and user groups.
Rick is also the author of Essential SQLAlchemy, a book published by O'Reilly that introduces the reader to the excellent SQLAlchemy Python database toolkit.
Table of Contents
Preface; Audience; Assumptions This Book Makes; Contents of This Book; Conventions Used in This Book; Using Code Examples; How to Contact Us; Acknowledgments; Chapter 1: Introduction to SQLAlchemy; 1.1 What Is SQLAlchemy; 1.2 The Object/Relational "Impedance Mismatch"; 1.3 SQLAlchemy Philosophy; 1.4 SQLAlchemy Architecture; Chapter 2: Getting Started; 2.1 Installing SQLAlchemy; 2.2 SQLAlchemy Tutorial; Chapter 3: Engines and MetaData; 3.1 Engines and Connectables; 3.2 MetaData; Chapter 4: SQLAlchemy Type Engines; 4.1 Type System Overview; 4.2 Built-in Types; 4.3 Application-Specific Custom Types; Chapter 5: Running Queries and Updates; 5.1 Inserts, Updates, and Deletes; 5.2 Queries; Chapter 6: Building an Object Mapper; 6.1 Introduction to ORMs; 6.2 Declaring Object Mappers; 6.3 Declaring Relationships Between Mappers; 6.4 Extending Mappers; 6.5 ORM Partitioning Strategies; Chapter 7: Querying and Updating at the ORM Level; 7.1 The SQLAlchemy ORM Session Object; 7.2 Querying at the ORM Level; 7.3 Contextual or Thread-Local Sessions; Chapter 8: Inheritance Mapping; 8.1 Overview of Inheritance Mapping; 8.2 Single Table Inheritance Mapping; 8.3 Concrete Table Inheritance Mapping; 8.4 Joined Table Inheritance Mapping; 8.5 Relations and Inheritance; Chapter 9: Elixir: A Declarative Extension to SQLAlchemy; 9.1 Introduction to Elixir; 9.2 Installing Elixir; 9.3 Using Elixir; 9.4 Elixir Extensions; Chapter 10: SqlSoup: An Automatic Mapper for SQLAlchemy; 10.1 Introduction to SqlSoup; 10.2 Using SqlSoup for ORM-Style Queries and Updates; 10.3 Using SqlSoup for SQL-Level Inserts, Updates, and Deletes; 10.4 When to Use SqlSoup Versus Elixir Versus "Bare" SQLAlchemy; Chapter 11: Other SQLAlchemy Extensions; 11.1 Association Proxy; 11.2 Ordering List; 11.3 Deprecated Extensions; Colophon;