A template query management tool. Define your common queries once, run them anywhere, with arbitrary filters.
beer-me [environment] <resource> [-f filter]
beer-me composes SQL queries from three things:
- A resource template — a
.sqlfile with your base query (noWHERE, no;) - An environment — a named database connection from
.envlist - Filters — injected at runtime via
-f
Without an environment argument, beer-me just prints the query. With one, it executes it.
# print the query (no execution)
beer-me record
# run against an environment
beer-me local record -f "id = 'some-uuid'"
# multiple filters (AND'd together)
beer-me local record -f "id = 'some-uuid'" -f "artist.age = 20"Defined in ~/.config/beer-me/.envlist, tab-separated:
LOCAL psql postgres://user:password@localhost:5432/my_database -c STAGING psql postgres://user:password@staging:5432/my_database -c
The first column is the environment name (case-insensitive, typically SCREAMING). The second is the command stub — beer-me concatenates the generated query to the end of it.
For psql, that means the stub must end with -c.
A resource is a template query stored at ~/.config/beer-me/<resource-name>.sql:
SELECT
table_1.*,
table_2.important_info AS table_2_info
FROM table_1
JOIN table_2 ON table_1.id = table_2.table_1_idTwo rules:
- No =WHERE= clause — beer-me builds this from your
-fflags - No trailing =;= — beer-me appends it after filter injection
Filters are appended as WHERE conditions, joined with AND:
beer-me record -f "column_name = 'value'"
beer-me record -f "\"column_name\" = 'double quotes'"handroll — spec-driven test data generation. beer-me investigates the data, handroll generates it.