Requirements
sqlcg
requires sqlc, dbmate, and Docker.
A sqlc.yaml
file. Example:
version: "2"
sql:
- engine: "mysql"
queries: "db/queries.sql"
schema: "db/schema.sql"
gen:
go:
package: "todos"
out: "repository/mysql/todos"
emit_empty_slices: true
Intent
sqlc
references dbmate, but doesn't demonstrate a useful workflow incorporating it.
sqlcg
allows a more iterative, interactive approach.
It:
- Launches
mysql:5.7
database. - Waits for it to accept connections.
- Runs the database migrations.
- Generates the Go code via sqlc.
- Connects to mysql shell for testing. (Optional with >=2 arguments.)
- Stops docker container.
Tips
Create a sqlcg
link somewhere in your path to make invoking this easier.
Future?
Postgres and SQLite database integration is likely.
Let me know in an issue if you'd like something else.