---
title: Python table helpers
description: Read governed tenant tables with validated identifiers and parameterized filters.
section: SDK
sidebarLabel: Python / Table helpers
order: 130
updated: "2026-06-11"
status: beta
llms: true
keywords:
  - Python
  - tables
  - fetch_table_rows
  - count_table_rows
---

The Python table helpers cover common read paths without hand-writing every `select` and `count`.

## Read rows

```python
from relpin_sdk import RelpinDb, fetch_table_rows

async def list_open_orders() -> dict[str, object]:
    with RelpinDb() as db:
        rows = await fetch_table_rows(
            db,
            "orders",
            columns=["id", "name", "status"],
            where={"status": "open"},
            order_by=[("created_at", "desc"), "id"],
            limit=50,
        )
    return {"orders": rows}
```

## Count rows

```python
from relpin_sdk import count_table_rows

total = await count_table_rows(db, "orders", where={"status": "open"})
```

## Safety rules

Identifiers are validated and quoted. Values travel as bind parameters. Invalid identifiers, order directions, or negative paging fail before a query runs.

Use raw SQL on the same governed transport when you need joins, aggregates, or a shape the helpers do not cover.
