Convert all hardcoded SQL into SQLAlchemy statements. Some might not be yet
optimal, but it is always easier to refactor.
Authored by: jruigrok 2007-11-22
Parent: [r6209]
Child: [r6211]