On Wednesday, April 3, 2019 at 1:40:16 PM UTC-4, Derek Lambert wrote: > > Thanks, that does make more sense. > > I ended up writing a little wrapper that allows me to create the query in > my service including the offset/limit and continue to add additional > filters, etc. when it's run. >
I actually do something similar. I often write queries with a class that exposes a `paginated` and `count` method, and a private '_core' to construct the base query for both. from my experience, two things to watch out for: * be sure to support order_by, especially when dealing with tests * if your project grows complex, you may need to use completely different queries for `total_count` and `data`. with simple queries and small datasets you don't... but i've written a handful of things where the `count` only needs to address one table but the `data` is built off a multi-table join and various relationship loading techniques. -- 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 sqlalchemy+unsubscr...@googlegroups.com. To post to this group, send email to sqlalchemy@googlegroups.com. Visit this group at https://groups.google.com/group/sqlalchemy. For more options, visit https://groups.google.com/d/optout.