The SQLAlchemy library was created by Mike Bayer to provide a high-level, Pythonic (idiomatically Python) interface to relational databases such as Oracle, DB2, MySQL, PostgreSQL, and SQLLite. "SQLAlchemy attempts to be unobtrusive to your Python code, allowing you to map plain old Python objects (POPOs) to database tables without substantially changing your existing Python code," says Copeland. "It includes a database server-independent SQL expression language and an object-relational mapper that lets you use SQL to persist your application objects automatically."
According to Copeland, more and more Python programmers are getting into database programming, particularly in the context of web development. "SQLAlchemy is arguably the best library for using relational databases from Python," Copeland says. "In comparison with SQLAlchemy, one popular competing object-relational mapper was described by Jonathan Ellis at PyCon 2007 as 'feeble.'
"It's already the default database layer in both the Pylons and TubrboGears web frameworks," Copeland adds. "Understanding the library better—which this book will help with—will make people more productive and help them write more maintainable 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 gives you both a good path to learning SQLAlchemy for the first tiem as well as providing a valuable reference for even veteran SQLAlchemy programmers," says Copeland.
Essential SQLAlchemy is the much-needed guide for every Python developer using this code library. Instead of a feature-by-feature documentation, the book takes an "essentials" approach that gives you exactly what you need to become productive with SQLAlchemy right away.
For a review copy or more information please email kathrynb@oreilly.com. Please include your delivery address and contact information.
Rick Copeland is a senior software engineer with retail analytics firm Predictix, LLC, where he uses SQLAlchemy extensively, primarily for web application development. He has been using Python full-time for development since 2005, in projects as diverse as demand forecasting, business web applications, compilers, and hardware synthesis.
Additional Resources:
For more information about the book, including table of contents, index, author bios, and cover graphic, see:
http://www.oreilly.com/catalog/9780596516147
Essential SQLAlchemy
Rick Copeland
ISBN: 9780596516147, 230 pages, $34.99 USD, £21.99 GBP
order@oreilly.com
1-800-998-9938
1-707-827-7000
About O’Reilly
O’Reilly Media spreads the knowledge of innovators through its books, online services, magazines, and conferences. Since 1978, O’Reilly Media has been a chronicler and catalyst of cutting-edge development, homing in on the technology trends that really matter and spurring their adoption by amplifying “faint signals” from the alpha geeks who are creating the future. An active participant in the technology community, the company has a long history of advocacy, meme-making, and evangelism.