wiko
wiko

Reputation: 453

Select range of rows in query

I have a function that takes page_size and skip as arguments. If page_size = 10 and skip = 2, I want to select 10 rows starting at row 21. I think this has to do with LIMIT and OFFSET. How do I do this in SQLAlchemy?

Upvotes: 2

Views: 1316

Answers (1)

davidism
davidism

Reputation: 127210

Use the limit and offset methods on the query.

session.query(...).limit(page_size).offset(skip)

Upvotes: 8

Related Questions