jouet db query
- Usage:
jouet db query [FLAGS] <SQL>
Run one read-only query and print its rows, cut to a limit
Runs one statement that reads: SELECT, WITH, VALUES, TABLE, SHOW or EXPLAIN, and PRAGMA in SQLite. The database enforces it, not only the statement's first word: SQLite is opened read-only and refuses a statement it says writes, and Postgres runs it alone in a READ ONLY transaction. Anything else, several statements, or a statement the database says writes, exits 4 with the reason, even with write rights.
Prints the first --limit rows, then how many more there are (counted without reading them, up to 100,000). Each value is cut to --width characters and the output to --budget bytes, with a marker saying what was left out. NULL prints as NULL. With --json, rows are arrays, with numbers, booleans and JSON as themselves.
Exits 1 when the database rejects the query (a syntax error, an unknown table), 5 when it cannot be reached, and 124 when the query runs past --timeout.
Examples: jouet db query 'select * from users order by id desc' jouet db query 'select status, count(*) from jobs group by 1' --url app.db jouet db query 'explain select * from orders where user_id = 7'
Arguments
<SQL>— The statement to run, one only
Flags
--limit <N>— The most rows to print (default 50)--width <CHARS>— The most characters to print of one value (default 80; 0 is no limit)--budget <BYTES>— The most bytes to print (default 8000; 0 is no limit)--timeout <DUR>— Stop the query after DUR, such as 30s or 2m (default 30s)--url <URL>— The database: a SQLite file, or a Postgres URL (default: DATABASE_URL)--remote— Allow a Postgres host that is not this machine-h --help— Print help