Get the number of rows in table using SQLAlchemy Get the number of rows in table using SQLAlchemy sql sql

Get the number of rows in table using SQLAlchemy


This should work

rows = session.query(Congress).count()

EDIT: Another way related to my first try

from sqlalchemy import funcrows = session.query(func.count(Congress.id)).scalar()