Query data with the CLI

Use scope query to execute ScopeQL after connecting the CLI. Start with a query that needs no sample data:

scope query 'SELECT 1 AS ready'

The result has one ready column with the value 1.

Read from a file or stdin

Pass a query inline, read it from a file with --file or -f, or pipe it through stdin. For the file examples, save this statement in report.scopeql:

report.scopeql
SELECT 1 AS ready

Run it from the file or stdin, or pass a statement directly:

scope query 'FROM system.tables LIMIT 10'
scope query -f report.scopeql --format json
scope query --format json < report.scopeql
scope query 'FROM system.tables LIMIT 10' --format csv > tables.csv

Choose an output format

Use --format for the result format and shell redirection to save results.

FormatOutput
tableA human-readable table; the default.
jsonOne JSON array of row objects.
jsonlOne JSON row object per line.
csvColumn names followed by CSV records.

The shell controls file permissions and overwriting; > can truncate a file before the query runs. Write to a temporary file and move it after success when an existing result must survive a failed query.

Limit waiting and handle cancellation

Queries have no additional client-side wait limit by default. Set --timeout 5m to limit waiting and attempt server cancellation when it expires; --timeout 0 disables that limit. This limit covers submission and waiting, excluding input, authentication, and output. Cancellation may take an additional five seconds. Server and network limits still apply.

Timeout and Ctrl+C diagnostics include the statement ID once one is available and describe the known outcome. The command keeps its timeout or interrupt exit code and writes no query results. If execution already completed, use its statement ID to retrieve the result over HTTP instead of rerunning a statement with side effects. An unconfirmed cancellation can leave the statement active; check its outcome before retrying.

Run scope --help or scope query --help for all current options. For query syntax and examples, use the query reference.