SQLAlchemy to construct a query
Alchemical query cleaned up