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 <outputtype>Output mode, valid values include: table(default) json, csv and text
-i, --infile <filename>Run query from the specified file if required, if specified any query provided
as an argument will be ignored
-q, --iqldata <filename>Source data for the command using a json or jsonnet file
--dryrunDry run flag; preprocessor only will run and output will returned
-i, --infile <filename>Run query from the specified file if required, if specified any query provided
as an argument will be ignored
-f, --outfile <filename>File to output results to if required (default behavior is to output results to the
console only)
-H, --helpPrint help information
-v, --verboseRun 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