PostgreSQL command-line client with auto-completion, syntax highlighting, and smart context-aware suggestions
pgcli is a command-line interface for PostgreSQL databases that enhances the standard psql client with interactive features. It provides real-time auto-completion for SQL keywords, table names, and column names, along with syntax highlighting using Pygments. The tool includes smart-completion that offers context-sensitive suggestions based on the current SQL statement.
The client supports standard PostgreSQL connection methods including connection strings, environment variables (PGHOST, PGPORT, PGUSER), and SSL configurations. It maintains compatibility with many psql back-slash commands and can connect to databases using DSN aliases configured in its configuration file. pgcli also includes features like automatic vertical output mode for wide results, configurable row limit prompts, and warnings for destructive queries.
Developers and database administrators working with PostgreSQL will find pgcli useful for interactive database exploration and query development. The tool can be integrated into IPython workflows through the pgcli.magic extension, allowing users to drop into a pgcli session from within IPython and have query results available as Python objects. It supports connection via Unix sockets, TCP connections, and can be run in Docker containers for isolated usage.
# via Homebrew
brew install pgcli
# via APT
sudo apt-get install pgcli
# via pip
pip install -U pgcli