Skip to content

Latest commit

 

History

History
76 lines (56 loc) · 3.63 KB

exec.md

File metadata and controls

76 lines (56 loc) · 3.63 KB
title exec
hide_title false
hide_table_of_contents false
keywords
stackql
infrastructure-as-code
configuration-as-data
cloud inventory
description The stackql exec command runs one StackQL statement or a script of statements, with flags for output format, authentication and the provider registry.
image /img/stackql-featured-image.png

Command used to run a StackQL query, either as a statement or as a batch of statements from a StackQL script (IQL File).


Syntax {#syntax}

stackql exec [query] [flags]


Arguments {#arguments}

Argument Description Example
query StackQL query to be performed
or command to be executed
"SELECT * FROM google.compute.instances
WHERE project = 'myproject' AND zone = 'us-east1-a'"
Note that the query must be enclosed in single or double quotes

Flags {#flags}

Flag Description
-o
--output
Output mode, valid values include: table (default), json, jsonl (newline delimited JSON, ndjson is accepted as an alias), csv, text and otel (OpenTelemetry log records, see Output Modes), example: --output jsonl
-i
--infile
Run query from the specified file if required, if specified any query provided as an argument will be ignored, example: --infile myquery.iql
-q
--iqldata
Source data for the command using a json or jsonnet file, example: --iqldata vars.jsonnet
--dryrun Dry run flag; preprocessor only will run and output will be returned
--var External variables (can be environment vars or secrets) sourced by jsonnet files specified using the --iqldata flag, example --var region=${AWS_REGION}
-f
--outfile
File to output results to if required (default behavior is to output results to the console only), example --outfile myoutput.csv
-h
--help
Print help information
-v
--verbose
Run queries in verbose mode with additional output sent to stdout, if the -f option is selected this additional logging information will be written to the output file along with the query results


> see [Global Flags](/command-line-usage/global-flags) for additional options

Examples {#examples}

Output query results to the console in table format:

stackql exec "SHOW services IN google"

Output query results to the console in json format:

stackql exec "SHOW services IN google" -o json

Output query results to a file in json format:

stackql exec "SHOW services IN google" -o json -f services.json

Execute query from an input file (IQL File) outputting the results to a file in json format:

stackql exec -i getservices.iql -o json -f services.json

Exit status {#exit-status}

exec exits with status 0 once the input has been processed; errors from individual statements are written to the console, so scripts should inspect the output. From v1.0 it exits with status 1 when a SET or UNSET configuration statement fails, when access management is enabled and a statement is refused, or when a preview IaC run reports a failed resource.