Skip to main content

exec

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


Syntax

stackql exec [query] [flags]


Arguments

ArgumentDescriptionExample
queryStackQL 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

FlagDescription
-o
--output
Output mode, valid values include: table(default) json, csv and text, example: --output json
-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
--dryrunDry run flag; preprocessor only will run and output will returned
--varExternal 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 for additional options


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