A simple Go CLI tool (using huh from Charm.sh) that helps you interactively create:
- A new PostgreSQL database
- A new PostgreSQL user
- Optional permissions for that user
Everything is done through an interactive terminal form.
- Interactive TUI using Charm's
huh - Creates a database
- Creates a user with a password
- Assigns the database owner
- Optional permission selection
- Uses standard PostgreSQL connection (
lib/pq)
Compile and move the binary somewhere on your PATH:
go build -o ~/.config/helpers_script/bin/dbscript ./cmd/dbscriptOr simply:
go build -o dbscriptThen run:
./dbscriptThe tool asks you for:
- Host (default:
localhost) - Port (default:
5432) - Admin username and password
- New database name
- New PostgreSQL username
- Password for that user
- Optional permissions (CONNECT, CREATE, TEMP)
After submitting the form, the tool runs:
CREATE DATABASE "<name>";
CREATE USER "<username>" WITH PASSWORD '<password>';
ALTER DATABASE "<name>" OWNER TO "<username>";
GRANT ...;- Go 1.21+
- A running PostgreSQL instance
lib/pqdriver (installed automatically via Go modules)
MIT