Skip to content

shadmeoli/interfactivePSQLDBCreate

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Postgres Database Creator CLI

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.


Features

  • 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)

Install

Compile and move the binary somewhere on your PATH:

go build -o ~/.config/helpers_script/bin/dbscript ./cmd/dbscript

Or simply:

go build -o dbscript

Then run:

./dbscript

How It Works

The 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 ...;

Requirements

  • Go 1.21+
  • A running PostgreSQL instance
  • lib/pq driver (installed automatically via Go modules)

License

MIT


About

A simple CLI to help you create postgres user and db interactively

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors