Chapter A.12. Updating Queries

Part of the reason that migration from SQLObject to SQLAlchemy is not too onerous is that SQLAlchemy has largely adopted SQLObject’s query style.

The first change you need to be aware of is that SQLObject’s q object for referring to columns has been named c in SQLAlchemy. Consider the case of a wiki:

    class Page(ActiveMapper):
        class mapping:
            pagename = Column(String(40), unique=True)
            data = Column(String)

In the equivalent SQLObject definition, if you want to query on pagename you do something like this: Page.select(Page.q.pagename > ‘F’). In SQLAlchemy, you would do this: Page.select(Page.c.pagename > ‘F’). The only difference between those two is that Page.q has been replaced by Page.c!

The operator ...

Get Rapid Web Applications with TurboGears: Using Python to Create Ajax-Powered Sites now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.