steampipe query
Execute SQL queries interactively, or by a query argument.
To open the interactive query shell, run steampipe query
with no arguments. The query shell provides a way to explore your data and run multiple queries.
If a query string is passed on the command line then it will be run immediately and the command will exit. Alternatively, you may specify one or more files containing SQL statements. You can run multiple SQL files by passing a glob or a space separated list of file names.
If the Steampipe service was previously started by steampipe service start
, steampipe will connect to the service instance - otherwise, the query command will start the service
. At the end of the query command or session, if other sessions have not connected to the service
already, the service
will be shutdown. If other session have already connected to the service
, then the last session to exit will shutdown the service
.
Usage
Run Steampipe interactive query shell:
steampipe query [flags]
Run a batch query:
steampipe query {query} [flags]
List available named queries:
steampipe query list
Flags
Flag | Description |
---|
Argument | Description |
---|---|
--export string | Export query output to a file. You may export multiple output formats by entering multiple --export arguments. If a file path is specified as an argument, its type will be inferred by the suffix. Supported export formats are sps (snapshot ). |
--header string | Specify whether to include column headers in csv and table output (default true ). |
--help | Help for steampipe query. |
--input | Enable/Disable interactive prompts for missing variables. To disable prompts and fail on missing variables, use --input=false . This is useful when running from scripts. (default true) |
--output string | Select the console output format. Possible values are line, csv, json, table, snapshot (default table) . |
--progress | Enable or disable progress information. By default, progress information is shown - set --progress=false to hide the progress bar. |
--query-timeout int | The query timeout, in seconds. The default is 0 (no timeout). |
--search-path strings | Set a comma-separated list of connections to use as a custom search path for the query session. |
--search-path-prefix strings | Set a comma-separated list of connections to use as a prefix to the current search path for the query session. |
--separator string | A single character to use as a separator string for csv output (defaults to ",") |
--share | Create snapshot in Turbot Pipes with anyone_with_link visibility. |
--snapshot | Create snapshot in Turbot Pipes with the default (workspace ) visibility. |
--snapshot-location string | The location to write snapshots - either a local file path or a Turbot Pipes workspace |
--snapshot-tag string=string | Specify tags to set on the snapshot. Multiple --snapshot-tag arguments may be passed. |
--snapshot-title string=string | The title to give a snapshot when uploading to Turbot Pipes. |
--timing | Turn on the query timer. |
--var string=string | Specify the value of a mod variable. Multiple --var arguments may be passed. |
--var-file string | Specify an .spvars file containing mod variable values. |
--watch | Watch SQL files in the current workspace (works only in interactive mode) (default true) |
Examples
Open an interactive query console:
steampipe query
Run a specific query directly:
steampipe query "select * from aws_s3_bucket"
Run a query and save a snapshot:
steampipe query --snapshot "select * from aws_s3_bucket"
Run a query and share a snapshot:
steampipe query --share "select * from aws_s3_bucket"
List the named queries available to run in the current mod context:
steampipe query list
Run a named query:
steampipe query query.s3_bucket_logging_enabled
Run the SQL command in the my_queries/my_query.sql
file:
steampipe query my_queries/my_query.sql
Run the SQL commands in all .sql
files in the my_queries
directory and concatenate the results:
steampipe query my_queries/*.sql
Run a specific query directly and report the query execution time:
steampipe query "select * from aws_s3_bucket" --timing
Run a specific query directly and return output in json format:
steampipe query "select * from aws_s3_bucket" --output json
Run a specific query directly and return output in CSV format:
steampipe query "select * from aws_s3_bucket" --output csv
Run a specific query directly and return output in pipe-separated format:
steampipe query "select * from aws_s3_bucket" --output csv --separator '|'
Run a query with a specific search_path:
steampipe query --search-path="aws_dmi,github,slack" "select * from aws_s3_bucket"
Run a query with a specific search_path_prefix:
steampipe query --search-path-prefix="aws_dmi" "select * from aws_s3_bucket"