Automatic JSON Output
When stdout is not a TTY (i.e., the CLI output is piped to another command), the CLI automatically switches to JSON output. Agents and scripts get structured data without specifying--format json:
Exit Codes
The CLI uses semantic exit codes for programmatic error handling:| Code | Name | Meaning |
|---|---|---|
0 | SUCCESS | Command completed successfully |
1 | GENERAL | Connection failure or unexpected error |
2 | USAGE | Invalid arguments or missing options |
3 | QUERY | SQL execution error |
4 | SECURITY | Read-only violation or forbidden operation |
5 | AUTH | Authentication failure |
Exit Code Routing
Agents can branch logic based on exit codes:Error Codes in JSON
When output is JSON, errors include a machine-readable error code:GENERAL_ERROR, USAGE_ERROR, CONNECTION_ERROR, QUERY_ERROR, SQL_ERROR, SECURITY_VIOLATION, AUTH_FAILURE, NOT_FOUND, TIMEOUT
NDJSON Streaming
Use--stream for newline-delimited JSON — one object per row. This is ideal for incremental processing of large result sets:
Dry Run for Planning
Agents can use--dry-run to preview SQL without executing. This is useful for query planning and validation before committing to execution:
File Output
Write results directly to a file for pipeline processing:Watch Mode for Monitoring
Repeatedly execute a command at a fixed interval. Useful for monitoring dashboards and alerting:Ctrl+C to stop.