A.1. A Quick Tour of SQLAlchemy
SQLAlchemy, which was first announced in October 2005, is a newer object relational mapper (ORM) than SQLObject. SQLAlchemy is influenced by Hibernate, SQLObject, and others; and can handle a number of cases that are difficult or impossible for SQLObject.
SQLAlchemy's power comes from a few different aspects of its design:
In addition, SQLAlchemy has some features that SQLObject lacks. It offers Oracle support and better support for compound and noninteger primary keys.
Here is a quick sample to show you what SQLAlchemy feels like. It's a data model for a simple wiki that allows tags to be applied to pages:
After running tg-admin sql create to build the database, we can play with it in an interactive session with tg-admin shell (the sample below was done with IPython installed):
This appendix introduces you to SQLAlchemy and its use within TurboGears. It is not a comprehensive reference or guide to SQLAlchemy. You can find excellent documentation at the official website, www.sqlalchemy.org.
In addition to covering the use of SQLAlchemy in TurboGears, this appendix provides some documentation for the ActiveMapper extension and a guide for migrating an application from SQLObject to SQLAlchemy.