Using COUNT(*) OVER() in current query with SQLAlchemy over PostgreSQL


So I could not find any examples in the SQLAlchemy documentation, but I found these functions:

And I managed to combine them to produce exactly the result I was looking for:

from sqlalchemy import func
query = session.query(Guest, func.count('total'))
query = query.filter(Guest.deleted == None)
query = query.order_by(
query = query.offset(0)
query = query.limit(50)
result = query.all()


P.S. I also found this question on Stack Overflow, which was unanswered.

# NOTE: I am not responsible for any expired content.
[email protected]:56:17+08:00
[email protected]:56:31+08:00
[email protected]://