Skip to content
Advertisement

How to skip records in SqlAlchemy query?

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?

Advertisement

Answer

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()
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement