You’ve got one for development, one for staging, one for production. Every teammate hacks together their own way of storing them. Some hide them in .env files. Others bury them in scripts. A few keep them in shell history without realizing it. This is brittle, hard to share, and a minefield for security.
There’s a better way: AWS CLI–style profiles for database URIs.
When you run aws configure, you set up named profiles, each with its own credentials. Switching profiles is as simple as adding --profile myprofile to a command. Now picture that, but for your database connections. A single config file. Named profiles. No guesswork. No overwriting other environments. No leaking secrets.
Why it beats the old way
- Profiles make onboarding cleaner. New teammates get one config file, zero hardcoded values.
- Switching environments is instant. No export/unset rituals or juggling tabs.
- Secrets stay out of source control. Profiles live in your home directory where they belong.
- Works well in CI/CD. Your pipelines call the right database without unsafe hacks.
How it works
You keep a plain text config file, maybe at ~/.dbprofiles. Each profile contains the URI, name, and any extra flags. Tools read from that file and connect without revealing the URI in shell history. Commands accept --profile the same way aws cli does. One flag, one switch, done.
Example:
[dev]
uri = postgres://user:pass@dev.example.com:5432/app
[staging]
uri = postgres://user:pass@staging.example.com:5432/app
[prod]
uri = postgres://user:pass@prod.example.com:5432/app
Then run:
db connect --profile staging
No need to paste the URI again. No need to remember it.
Why AWS CLI–style profiles work for database URIs
Credentials sprawl is a silent killer in teams. Profiles give you central control. They keep settings predictable and safe. They shrink mental load. You’ll never again be afraid of running a production migration from the wrong terminal window.
If you want to see this in action without writing a full tool from scratch, you can spin it up with Hoop.dev. You get AWS CLI–style profiles for database URIs out of the box. Configure once, connect in seconds, and share configs without leaking secrets.
Your database deserves the same clarity and safety as your cloud. You can have it running live in minutes.