Reputation: 114
I have 100 rows in my DB. I'm trying to execute select query but I want to skip the first 10 rows (i.e. I want rows in range 11-20).
How can I do this?
Upvotes: 3
Views: 7101
Reputation: 3037
The raw SQL is like:
SELECT * FROM table LIMIT 10 OFFSET 10
In SqlAlchemy language it's like:
Table.query.limit(10).offset(10).all()
Upvotes: 10
Reputation: 17323
You can use limit() and offset(), like this:
foos = session.query(Foo).offset(10).limit(10)
Which will construct a query like this:
select * from foos offset 10 limit 10
Upvotes: 3