pg - PostgreSQL Lord of the Ring¶

One tool to rule them all - A unified interface for PostgreSQL client tools
Say goodbye to remembering different syntaxes for each PostgreSQL tool! pg provides one consistent command-line interface for psql, pg_dump, pg_restore, createdb, and more.
Quick Example¶
Key Features¶
- 🎯 Unified syntax for all PostgreSQL tools
- 🔌 Service file support - the elegant way to connect
- 📦 Zero dependencies - pure bash
- 🛠️ Full compatibility - all original features preserved
- 🚨 Clear distinction between logical dumps and physical backups
Common Commands¶
| What you want to do | Command |
|---|---|
| Connect to database | pg query -s production mydb |
| Export database | pg dump db -s production myapp backup.sql |
| Import database | pg dump import -s production myapp backup.sql |
| Create database | pg create db -s production newapp |
| Run maintenance | pg maintain vacuum -s production mydb |
| Check server status | pg info ready -s production |
Next Steps¶
- Installation - Get pg installed in minutes
- Quick Start - Your first commands
- Connection Options - Master the service file approach
- Command Reference - Complete command list
Why Service Files?¶
The examples above use -s production which refers to entries in ~/.pg_service.conf:
This approach is:
- Secure - No passwords on command line
- Maintainable - Change connection details in one place
- Clean - Simple, readable commands
- Professional - How experienced PostgreSQL DBAs connect
Ready to simplify your PostgreSQL workflow? Let's get started!