I typed one command and my database connection felt like wielding AWS CLI — but for Postgres.
Typing pgcli --profile staging connected me to the staging database instantly, no fumbling with long connection URIs or environment variables. AWS CLI-style profiles in pgcli are a game changer when you work with multiple Postgres databases across projects, teams, or environments.
With AWS CLI, you switch between profiles like aws --profile production s3 ls. Imagine the same for pgcli: profiles stored in one config file that map names to connection strings. Now you can run pgcli --profile production and jump straight into your production database shell. No more exporting PGHOST or PGPASSWORD. No need to remember parameters.
To set it up, create or edit your pgcli config file. It usually lives in ~/.config/pgcli/config. Add sections named after your profiles:
[production]
host = prod-db.company.com
user = admin
dbname = main
password = securepassword
[staging]
host = staging-db.company.com
user = dev
dbname = app_dev
password = anotherpassword
After saving, connecting is effortless:
pgcli --profile production
pgcli --profile staging
You get tab-completion, syntax highlighting, and query formatting just like normal pgcli, but now with AWS CLI-style clarity and speed. Switching databases becomes muscle memory.
This method works well for local development, cloud environments, and CI/CD pipelines. It also makes onboarding new engineers faster: give them a single config file with all profiles preloaded, and they can explore or debug the right database with zero guesswork.
The payoff is small friction erased forever. Every keystroke saved compounds over time.
If you want to see AWS CLI-style profiles in pgcli running live, without touching your local machine or setting up configs, head to hoop.dev and you can connect to any Postgres database in minutes.