Run SQL (read-only)
queryRun read-only SQL queries against PostgreSQL and retrieve result rows. Writes, DDL, and admin functions are blocked before execution. Supports pagination with limit and offset; returns up to 1000 rows by default (max 10000).
Instructions
Run a read-only SQL query and return rows. Writes, DDL and administrative functions are refused before the statement reaches the database. At most 1000 rows come back unless you pass limit (server maximum 10000); truncated: true in the response means there is more data — page through it with offset, and give the query an ORDER BY when you do, or the rows you get on page two depend on the planner's mood.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| sql | Yes | a single read-only statement: SELECT, WITH, VALUES, EXPLAIN or SHOW (write `SELECT * FROM t`, not `TABLE t`) | |
| limit | No | maximum rows to return; larger values are capped at 10000 and the response says so | |
| offset | No | rows to skip, for paging; pair it with ORDER BY for stable pages | |
| database | No | which configured database to use; omit when only one is configured |