I have the following code:
session = Session()
query = session.query('count').from_statement(
"""
SELECT COUNT(DISTINCT autoresponder.campaign_id) as count
FROM autoresponder
WHERE autoresponder.account_id=:account_id AND autoresponder.is_active='t'
"""
).params(account_id=account_id).all()
print query[0].count
But I am trying to understand SQLAlchemy better and want to transform the above SQL statement into a SQLAlchemy ORM object that just returns the a count of distinct rows.