Using SQLAlchemy

Creating Models

In the initial modeling phase you should aim for a strongly normalised database layout. Normalisation blends very well with Object-Relation mapping and allows easy enhancement of the model.

Committing changes

Normally changes get committed by the transaction manager. To commit your changes prematurely you can not use the commit method provided by the Session, but have to call the transaction manager directly:

import transaction
transaction.commit()

This unmaps all objects from the current session.

You can send your queries to the database by flushing the session:

model.DBSession.flush()

Some SQLAlchemy commands, like query, automatically issue a flush.