Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get length of query result SqlAlchemy

I have simple query using SqlAlchemy ORM:

query = DBsession.query(AssetsItem).filter_by(
    AssetsItem.id > 10,
    AssetsItem.country = 'England'
)

How can i get length of my query result. I want to know how much AssetsItem i would get by this query

like image 645
Vladyslav Avatar asked Aug 16 '17 21:08

Vladyslav


1 Answers

query = DBsession.query(AssetsItem).filter_by(
AssetsItem.id > 10,
AssetsItem.country = 'England'
)
your_count = query.count()

Documentation

like image 100
Jugurtha Hadjar Avatar answered Sep 28 '22 00:09

Jugurtha Hadjar