Setting the Database

Most public mods are written without specifying a database on each query. As a result, all queries in the mod run against the 'default' database. By default, the database is local Steampipe instance (postgres://steampipe@localhost:9193/steampipe). The reason for this is partly historical; dashboards and benchmarks were originally built-in to Steampipe. When we separated these features into separate products, we did not want to break compatibility with the large library of existing mods.

It is possible, however, to set a different default database for your mod. To do so, you can set the database argument in your mod definition.

The database can be a connection string for a Postgres database, but Powerpipe also supports MySQL:

and SQLite:

and DuckDB:

You probably don't want to hardcode the connection string in your mod though. The connection string may include your database password, and you probably want to let the user choose which database to use at run time. The preferred approach is a to use a variable to set the database, and use a connection to set the default instead of the actual connection string.

Now when a user runs your mod they can either use the default connection:

or they can pass the variable to override it:

For the database connection types (connection.steampipe, connection.postgres, connection.mysql, connection.duckdb, connection.sqlite), Powerpipe even supports passing them as connection strings:

or pipes workspaces (you will need to log in first)!