Batch Queries
Steampipe queries can provide valuable insight into your cloud configuration, and the interactive client is a powerful tool for ad hoc queries and exploration. Often, however, you will write a query that you will want to re-run in the future, either manually or perhaps as a cron job. Steampipe allows you to save your query to a file, and pass the file into the steampipe query command.
For example, lets create a query to find S3 buckets where versioning is not enabled. Paste the following snippet into a file named s3_versioning_disabled.sql:
We can now run the query by passing the file name to steampipe query
You can even run multiple sql files by passing a glob or a space separated list of file names to the command:
Query output formats
By default, the output format is table, which provides a tabular, human-readable view:
You can use the --output argument to output in a different format. To print your output to json, specify --output json:
To print your output to csv, specify --output csv:
Redirecting the output to CSV is common way to export data for use in other tools, such as Excel:
To use a different delimiter, you can specify the --separator argument. For example, to print to a pipe-separated format: