Skip to content

Output Formats

Berkay Günaydın edited this page Aug 6, 2026 · 1 revision

Output Formats

propq adapts its output to how you're using it: humans get tables, scripts get JSON, spreadsheets get CSV.

Table (default)

propq -s prod --sql "SELECT id, name FROM users"

When stdout is a terminal, results render as a colored table with a summary line (✓/✗ per target). Output auto-pages through less -SRFX when it's long — search with /, scroll, quit with q.

Pager behaviour:

  • Auto: pager only when stdout is a TTY and output is long.
  • --pager: force paging even when stdout is piped.
  • --no-pager: disable entirely (e.g. inside scripts that capture output).
  • Honors the PAGER environment variable (defaults to less -SRFX).

JSON (--json)

Machine-readable, stable schema — designed for AI agents and scripts.

propq --json --sql "SHOW TABLE STATUS" -s prod

Per-target result object:

{
  "server": "prod-eu-1",
  "database": "shop_main",
  "status": "OK",
  "rows": {
    "columns": ["id", "name"],
    "rows": [["1", "alice"], ["2", "bob"]]
  },
  "affected": 0,
  "elapsed": "12.3ms"
}
Field Type Description
server string Server name (config key)
database string Database targeted
status string OK, ERR, or SKIP
rows object Present for SELECTs: columns + rows (all values as strings)
affected int Rows affected (for DML)
error string Error message, present only when status is ERR
elapsed string Per-target duration, e.g. "12.3ms"

propq servers --json emits the server list in the same structured style.

CSV (--csv)

propq --csv --sql "SELECT id, name, email FROM users" -s prod > users.csv

Flat CSV with a header row — opens directly in Excel/LibreOffice.

Streaming (--stream)

propq -s "www1|www6|www7" --sql "SELECT VERSION()" --stream

Prints each result as it completes instead of waiting for all targets. On slow servers you see fast ones appear immediately. Works with any output format.

History (--history)

propq --history

Shows recent queries from the local history store — the same history that pre-fills the editor in -e mode.

Output control flags

Flag Effect
-o, --output FILE Write output to a file too (stdout still gets it)
-N, --no-output Suppress result rows — summary only
--no-error Drop error entries from the output
--no-result Show only ✓/✗ status per target, no data rows
-q, --quiet Suppress spinner and banner noise

Typical combos

# CI check: just pass/fail signal
propq --json --dry-run --sql "DROP TABLE temp" -s prod

# Export for Excel
propq --csv -o users.csv --sql "SELECT * FROM users" -s prod

# Live tail-style monitoring
propq -s "www1|www6" --sql "SELECT COUNT(*) FROM sessions" --stream

# Quiet machine log line
propq -q --json -s prod --sql "SELECT 1" | jq -r '.[].status'

Next: Safety

Clone this wiki locally