SQLObject is a popular Object Relational Manager for providing an object interface to your database, with rows as instances, tables as classes and columns as attributes.
SQLObject includes a Python-object-based query language that makes SQL more abstract, and provides substantial database independence for applications.
Example
Examples are good. Examples give a feel for the aesthetic of the API, which matters to me a great deal. This is just a snippet that creates a simple class that wraps a table:
>>> from sqlobject import *
>>>
>>> sqlhub.processConnection = connectionForURI('sqlite:/:memory:')
>>>
>>> class Person(SQLObject):
... fname = StringCol()
... mi = StringCol(length=1, default=None)
... lname = StringCol()
...
>>> Person.createTable()
SQLObject supports most database schemas that you already have, and can also issue the CREATE statement for you (seen in Person.createTable()).
Here's how you'd use the object:
>>> p = Person(fname="John", lname="Doe")
>>> p
>>> p.fname
'John'
>>> p.mi = 'Q'
>>> p2 = Person.get(1)
>>> p2
>>> p is p2
True
Product's homepage
What's New in This Release: [ read full changelog ]
· Strings are treated specially in Select to allow Select(['id, 'name'], where='value = 42').
· ForeignKey('Table', refColumn='refcol_id') allows ForeignKey to point to a non-id column.
· Support for PostgreSQL 7.* is dropped; the minimal supported version of PostgreSQL is 8.1.
· Quoting rules have changed for PostgreSQL: SQLObject uses the E'' escape string.
· A bug caused by psycopg2 recently adding a new Boolean non-callable autocommit attribute was fixed.
· sqlobject.__doc__ and main.__doc__ no longer contain the version number: use sqlobject.version or version_info.