---
title: "💭 Read a Range of Data - LIMIT and OFFSET - SQLModel"
description: "!https://sqlmodel.tiangolo.com/tutorial/limit-and-offset/?h=#combine-limit-and-offset-with-where"
date: 2023-08-01
published: true
tags:
  - python
  - thought
template: link
---


<div class="embed-card embed-card-external">
  <a href="https://sqlmodel.tiangolo.com/tutorial/limit-and-offset/?h=#combine-limit-and-offset-with-where" class="embed-card-link" target="_blank" rel="noopener noreferrer">
    <div class="embed-card-image">
      <img src="https://sqlmodel.tiangolo.com/assets/images/social/tutorial/limit-and-offset.png" alt="Read a Range of Data - LIMIT and OFFSET - SQLModel — SQLModel, SQL databases in Python, designed for simplicity, compatibility, and robustness." loading="lazy">
    </div>
    <div class="embed-card-content">
      <div class="embed-card-title">Read a Range of Data - LIMIT and OFFSET - SQLModel</div>
      <div class="embed-card-description">SQLModel, SQL databases in Python, designed for simplicity, compatibility, and robustness.</div>
      <div class="embed-card-meta">sqlmodel.tiangolo.com</div>
    </div>
  </a>
</div>


Implement paging in sqlmodel with where, limit, and offset.

``` python
def select_heroes():
    with Session(engine) as session:
        statement = select(Hero).where(Hero.age > 32).limit(3)
        results = session.exec(statement)
        heroes = results.all()
        print(heroes)
```

!!! note

    This post is a <a href="/thoughts/" class="wikilink" data-title="Thoughts" data-description="These are generally my thoughts on a web page or some sort of url, except a rare few don&#39;t have a link. These are dual published off of my..." data-date="2024-04-01">thought</a>. It's a short note that I make
    about someone else's content online <a href="/tags/thoughts/" class="hashtag-tag" data-tag="thoughts" data-count=2 data-reading-time=3 data-reading-time-text="3 minutes">#thoughts</a>
