Skip to main content

mr query create

Create a new saved query. Requires --name (unique label) and --text (the SQL body). --template is optional and lets you embed a Pongo2 template that receives the query's result rows for custom rendering in the web UI. Query Text runs against a read-only handle when executed; writes to the database via query run are rejected.

Usage

mr query create

Examples

Create a minimal query

mr query create --name "count-resources" --text "select count(*) as n from resources"

Create with a template for custom display

mr query create --name "recent-notes" --text "select id, name from notes order by created_at desc limit 10" --template "{{ rows|length }} rows"

Flags

FlagTypeDefaultDescription
--namestring``Query name (required) (required)
--textstring``Query text/SQL (required) (required)
--templatestring``Query template

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

Created query object with ID, Name, Text, Template, Description, CreatedAt, UpdatedAt

Exit Codes

0 on success; 1 on any error

See Also