- This is a web interface with blade database project that translates the postgresql commands to http commands for easy use as the backend in the BladeDB.
- Run the following command:
- macOS:
psql postgres
- Linux:
sudo -u postgres psql
- macOS:
- Create a new database in posgres client represented by:
postgres=#- To create a new database use command:
CREATE DATABASE blade;
- Then connect to the new database:
\c blade
- This will update the cli prompt to:
blade=#
- This will update the cli prompt to:
- Linux only Set the user password:
ALTER USER postgres PASSWORD 'postgres';
- Get your connection string of the format:
protocol://<username>:<password>@host:port/database- Let's call this
access_key. - Test it using
psql, example:psql "postgres://username:password@localhost:5432/blade"- It will open a postgres client with blade db active. Exit using
\qcommand.
- It will open a postgres client with blade db active. Exit using
- Let's call this
-
For managing the schema of the database, we are using
goose: -
Use command:
$: go install github.com/pressly/goose/v3/cmd/goose@latest
-
Once installed, there are schema management files available in directory
/sql/schema, when in that directory use command:$: goose postgres "<access_key>" upto build the database in the PostgreSQL, and:
$: goose postgres "<access_key>" downto undo the build.
- For implementing data injection into database, with proper input cleaning, we are using
SQLC. - Install it using:
go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
