docstring

This commit is contained in:
Curtis Castrapel 2018-05-24 15:21:38 -07:00
parent 9ccd43c29b
commit 5e3add0b81
1 changed files with 5 additions and 0 deletions

View File

@ -268,6 +268,11 @@ def clone(model):
def get_count(q): def get_count(q):
"""
Count the number of rows in a table. More efficient than count(*)
:param q:
:return:
"""
count_q = q.statement.with_only_columns([func.count()]).order_by(None) count_q = q.statement.with_only_columns([func.count()]).order_by(None)
count = q.session.execute(count_q).scalar() count = q.session.execute(count_q).scalar()
return count return count