On Monday, April 1, 2019 at 12:10:52 PM UTC-4, Derek Lambert wrote:
> Is it possible to return a query's results as a dictionary containing the 
total count and a limited portion of the results?


You'd be a lot better off trying to accomplish this with a simple helper 
function than trying to change what query/all actually returns.


def pretty_results(query):
    return {
       'total_count': query.count(),
       'data': query.offset(0).limit(50).all(),
       }



-- 
SQLAlchemy - 
The Python SQL Toolkit and Object Relational Mapper

http://www.sqlalchemy.org/

To post example code, please provide an MCVE: Minimal, Complete, and Verifiable 
Example.  See  http://stackoverflow.com/help/mcve for a full description.
--- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sqlalchemy.
For more options, visit https://groups.google.com/d/optout.

Reply via email to