Postgres CLI with autocompletion and syntax highlighting
pgcli is an interactive command-line client for PostgreSQL that enhances the standard psql experience with modern features like auto-completion and syntax highlighting. Built using Python Prompt Toolkit, it provides intelligent suggestions as you type, including SQL keywords, table names, and column names based on your database schema. The tool offers context-sensitive completion, so typing "SELECT * FROM" will only suggest table names, while "SELECT * FROM users WHERE" will suggest column names from the users table.
The tool is designed for database administrators, developers, and anyone who frequently works with PostgreSQL databases and wants a more user-friendly command-line interface. It supports all the standard PostgreSQL connection methods including connection strings, environment variables (like PGHOST, PGPORT), and SSL connections. pgcli also includes primitive support for psql back-slash commands and pretty-prints query results in tabular format, making it a drop-in replacement for psql with enhanced usability.
Beyond basic database interaction, pgcli offers advanced features like IPython integration for data analysis workflows, Docker support for containerized environments, and extensive configuration options. The tool automatically creates a config file on first launch, allowing users to customize their experience. Whether you're running quick queries, exploring database schemas, or performing complex data analysis, pgcli provides a more intuitive and efficient interface than traditional command-line database clients.
# via Homebrew
brew install pgcli
# via APT
sudo apt-get install pgcli
# via pip
pip install -U pgcli