- CLI - good for
- low bandwidth environments (talking to cloud servers)
- very fast interactions for users that already know which command to use
- can use scripts and the alias command to create powerful custom commands
- GUI - good for
- exploring functionality & learning
- Seeing structure and organization - how things relate to each other
- Stay local - exhaust your local resources before googling
- Built-in help
pg_ctl --help
psql --help
psql
\q
command
- man pages (Try these in your shell)
man man
man zsh
(orman bash
)man pg_ctl
man psql
- Built-in help
- Practice reading text that is hard to read
- You may have to force yourself to keep reading every line when you feel lost.
- Skim & scan to get an overview, then read for detail
- This skill also helps with reading error messages
- This skill also helps with reading code
- Have a clear idea of what the CLI is supposed to do. (See if you can say a simple statement like "I want to list databases")
- Keep a notebook in a text file with a selection of command strings and what they do
- Your goal is not just to get a quick answer. It's to build your brain muscles to work in this text-heavy, jargon-filled environment.
- Powershell?
- gitbash?
- bash/zsh?
- psql?
- text pager?
Look at the prompt. Are you in zsh? psql? a text pager?
Which user interface should I use for the command to ...
- ... create a user role?
createuser
orpsql
or dbeaver? - ... create a database?
createdb
orpsql
or dbeaver? - ... run a SQL script?
psql
or dbeaver?
Try them all before forming habits.
I tend to do something similar to this whenever I start working on express/postgres:
- Reboot the machine (Really! Just do it. Every day at least.)
- Log in to your development account (if your normal account is having trouble installing tools, create a fresh account on your laptop)
- Launch a command line shell
- In shell: Navigate to your project folder
- In shell: Launch postgresql database server
- Launch database client (
psql
or dbeaver) & verify server is running - In shell: Launch vscode (
code .
) - Pick a CLI - your shell or a vscode terminal - and stick with it
- Run tests (
npm test
) or server (npm run dev
) from that CLI and only that CLI
You should always have these tools available:
- postgresql database server
- CLI shell in project folder
- Database client (
psql
, dbeaver, or both) - vscode
- Postman
- Is the postgresql server running? (
pg_ctl status
) - Is only one instance of node/express running? (
ps
) - Is my connection spec correct? (use dbeaver to test connection)
- Am I in the right CLI? (look at the prompt characters)