Skip to main content

mr query run

Execute a saved query by ID and return the rows as JSON. The query runs against a read-only database handle: any attempt to write (INSERT/UPDATE/DELETE/DDL) is rejected. Column names in the result come verbatim from the SELECT list, so use explicit column aliases (select count(*) as n ...) to produce predictable keys.

Returns 400 Bad Request if the SQL fails to execute and 404 Not Found if the given ID does not exist. For templated queries, the request body/form values are bound as named SQL parameters.

Usage

mr query run <id>

Positional arguments:

  • <id>

Examples

Run a query by ID and print the raw JSON array

mr query run 42

Run and extract the first row's count column with jq

mr query run 42 --json | jq '.[0].n'

Flags

This command has no local flags.

Inherited global flags

FlagTypeDefaultDescription
--jsonboolfalseOutput raw JSON
--no-headerboolfalseOmit table headers
--pageint1Page number for list commands (default page size: 50)
--quietboolfalseOnly output IDs
--serverstringhttp://localhost:8181mahresources server URL (env: MAHRESOURCES_URL)

Output

Array of row objects; each object's keys are the query's selected column names

Exit Codes

0 on success; 1 on any error

See Also