pgcli
CLI for Postgres Database. With auto-completion and syntax highlighting.
What it is and what it does
pgcli is a PostgreSQL client that replaces the standard psql command-line tool with an interactive shell featuring auto-completion and syntax highlighting. It uses prompt_toolkit to provide a modern terminal interface that suggests SQL keywords, table names, and column names as you type, and highlights syntax using Pygments. The tool supports both direct database names and full PostgreSQL connection URIs, environment variables for authentication (PGHOST, PGPORT, PGUSER, PGPASSWORD, PGDATABASE), and SSL connection options.
You run it from the command line to open an interactive session with a PostgreSQL database. It displays query results in formatted tables and supports configuration through a config file at ~/.config/pgcli/config. The package is built on established dependencies: psycopg for database connectivity, click for command-line argument parsing, sqlparse for SQL parsing, and cli_helpers for output formatting.
Use it for:
- Interactive database exploration and ad-hoc querying with real-time auto-completion of table and column names
- Development workflows where syntax highlighting and smart suggestions reduce typing and errors
- Remote PostgreSQL administration via SSH tunnels or direct connections with SSL support
- Learning SQL with guided completion that shows available tables and columns in context
- Scripting and automation via command-line invocation with DSN aliases from config files
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
pgcli is a command-line interface for PostgreSQL that provides auto-completion for SQL keywords, table and column names, and syntax highlighting as you type.
Yes. pgcli is actively maintained, has no known vulnerabilities, installs with low friction, and is licensed permissively. It is a straightforward productivity tool for PostgreSQL users who want a more modern interactive shell than psql. Install it if you regularly work with PostgreSQL from the command line and value auto-completion and syntax highlighting.
Install
pgcli on PyPI
pip
pip install pgcliuv
uv add pgclipoetry
poetry add pgcliInstalling pgcli
Before you install
Low install friction with a pure Python wheel distribution. Actively maintained with a release within the last 72 days. Requires Python 3.10 or later and depends on 11 runtime packages including psycopg for database connectivity and prompt_toolkit for the interactive interface.
License in practice
BSD license is permissive, allowing free use, modification, and distribution with minimal restrictions—suitable for both open-source and commercial projects.
Quickstart
$ pip install pgcli
$ pgcli local_database
or
$ pgcli postgresql://user:password@host:5432/dbname
Requires a PostgreSQL server to connect to; psycopg (the database driver) must be able to reach a running PostgreSQL instance.
Verify before relying
- Whether smart-completion (context-sensitive suggestions based on SQL keywords) works reliably across all query patterns
- Performance characteristics when connecting to databases with very large schemas (thousands of tables/columns)
- Extent of psql back-slash command support and which commands are fully implemented
Package facts
| License | BSD (permissive) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 11 — pgspecial, click, Pygments, prompt_toolkit, psycopg, psycopg-binary, sqlparse, configobj, cli_helpers, setproctitle, tzlocal |
| Maintenance | actively maintained — 72 days since the last release |
| First released | |
| Downloads | 647,300/month — #5,593 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pgcli-4.5.0-py3-none-any.whl
Tags
More Software Development packages
Provides backported and experimental type hints…
permissive · top 100 on PyPI
numpyNumPy provides an N-dimensional array object…
permissive · top 100 on PyPI
fastapiFastAPI is a Python web framework for building…
permissive · top 100 on PyPI
annotated-docProvides a way to document function parameters,…
permissive · top 100 on PyPI
typerTyper builds command-line applications from…
permissive · top 1,000 on PyPI
distlibDistlib provides low-level packaging utilities…
permissive · top 1,000 on PyPI
litecliA command-line client for SQLite databases with…
permissive · top 15,000 on PyPI
pgspecialExecutes PostgreSQL meta-commands (backslash…
permissive · top 15,000 on PyPI
myclimycli is a command-line client for MySQL and…
permissive · top 15,000 on PyPI
pgsanityPgSanity validates PostgreSQL SQL syntax by…
permissive · top 15,000 on PyPI
postgres-mcpA Model Context Protocol server that connects…
permissive · top 15,000 on PyPI
pulumi-postgresqlPulumi resource provider for declaring and…
permissive · top 15,000 on PyPI
postgresProvides a lightweight abstraction layer over…
permissive · top 15,000 on PyPI
pgdbWraps PostgreSQL connections to return query…
permissive · top 15,000 on PyPI
adbc-driver-postgresqlProvides a DBAPI 2.0-compatible Python…
permissive · top 5,000 on PyPI
pg8000pg8000 is a pure-Python PostgreSQL driver that…
permissive · top 1,000 on PyPI