Expand description
db query — execute arbitrary single-statement read-only SQL
against the CLI’s local postgres pool. Returns the row set as
typed JSON cells (Postgres → JSON via a per-cell decoder),
with column metadata and the wire-protocol command tag.
Constraints:
- Read-only: wrapped in
SET LOCAL TRANSACTION READ ONLYserver-side. Write attempts come back asError::QueryReadOnlyViolation. - Timeout: the
RequestBaseenvelope’s optional--timeout(humantime:30s,5m,1h30m). When set, the CLI threads it to postgres asSET LOCAL statement_timeout/lock_timeout— enforcement is the server’s alone. When omitted, the query runs uncapped.
Multi-statement queries, COPY … TO STDOUT|STDIN, and
transaction-control verbs (BEGIN / COMMIT / ROLLBACK)
are rejected up front by a cheap leading-token scan on the
CLI side before the query reaches the database.
Modules§
Structs§
- Args
- Column
- One result column.
r#typeis the Postgrespg_type.typname(e.g."int8","text","jsonb","timestamptz"). Callers needing precision/scale/array-element-type can inspect the name; richer typeinfo is deferred. - Command
- Request
- Response
- Unary response from
db query.