2022-02-19
I have recently become a fan of saving common SQL queries in a Makefile to be able to run independent of codebase state. It's been useful in development to delete test data and gain insight into the database state.
define SQL_SELECT
SELECT id, name
FROM database.table
LIMIT 1
endef
export SQL_SELECT
sql-select-example:
mysql -e "$$SQL_SELECT\G"
make sql-select-example
# *************************** 1. row ***************************
# id: 123
# name: example