dbcli

pgcli: An Interactive PostgreSQL Command-Line Client

pgcli is a Python terminal client for PostgreSQL with context-aware SQL completion, syntax highlighting, and formatted results. It suits developers and database users who want a more helpful interactive alternative to psql.

ActivePythonBSD-3-ClauseCLIDatabaseTerminal
View on GitHub Compare
Stars
13.4k
Forks
610
Stars, last 30 days
+28
Last commit
20 days ago
Contributors
100+

Our take

Activeregular commits and releases

Health score

52/100

How it is scored
Activity
52
Community
86
Issues
35
Pull requests
35

+28 stars in the last 30 days

  • More contributors than 78% of the projects we track
  • Slower to close issues than 97% of the projects we track

pgcli is an actively maintained, broadly contributed PostgreSQL CLI that adds practical editing and display help while keeping the workflow in the terminal.

Good fit if

  • You use PostgreSQL interactively and want completion based on SQL context and database schema.
  • You prefer a terminal client with syntax highlighting and readable tabular output.
  • You want a BSD-3-Clause licensed Python tool with recent commits and releases and contributions spread across many developers.

Look elsewhere if

  • You need a graphical database client rather than a terminal REPL.
  • You require full psql backslash-command compatibility, since pgcli describes its support as primitive.
  • Your environment cannot run Python 3.10 or newer and you cannot use the available Docker installation option.
All health signals
Last commit2026-09-20 (20 days ago)
Commits, last 90 days30
Releases, last 12 months2 (latest v4.7.1, 2026-09-20)
Contributors100+ (top contributor: 34% of commits)
Issues closed, last 90 days7 (typically closed in 597 days)
Pull requests merged, last 90 days25 (typically merged in 13 days)
Project age12 years

Checked on 2026-10-11 with the GitHub API.

Project history

Daily GitHub snapshots since Oct 7, 2026. History covers stars and forks; health signals are not tracked historically.

Selected snapshot

Stars

13,446

Forks

619

Change since Nov 13, 2026: +1 stars·+1 forks

Overview

pgcli is an interactive command-line client for PostgreSQL. It improves on a basic SQL prompt by suggesting relevant tables, columns, and SQL keywords as you type, and by highlighting queries and formatting results.

It is aimed at people who work with PostgreSQL in a terminal, from developers iterating on queries to database users inspecting data. It also offers basic support for psql backslash commands and can be used from IPython.

Key Features

  • Suggests SQL keywords, tables, and columns during query entry.
  • Offers context-sensitive completion, such as table suggestions after FROM and column suggestions after WHERE.
  • Highlights SQL syntax and prints query results in formatted tables.
  • Supports PostgreSQL connection strings, common PG* environment variables, SSL settings, and configured DSN aliases.
  • Provides options for row-limit prompts, destructive-query warnings, and automatic vertical output for wide results.
  • Includes primitive support for psql backslash commands.
  • Can run in Docker or be invoked from an IPython session.

Use Cases

  • Developers can explore a PostgreSQL database and draft queries in a terminal with schema-aware suggestions.
  • Analysts and database operators can run ad hoc SQL and read formatted results without leaving the command line.
  • Teams using PostgreSQL over SSL or with multiple configured connections can use familiar connection variables, connection strings, or DSN aliases.
  • Python users can work on SQL in an IPython session and bring query results back into their workspace.

What you need

Detected in the repository

  • Python >=3.10 (from pyproject.toml)
  • A Dockerfile, so it can run in a container
  • A test suite and automated checks on GitHub Actions

License in plain words

BSD-3-Clausepermissive

  • Commercial use: yes
  • Modify and redistribute: yes
  • You must keep: the copyright and license notice; the authors' names cannot endorse your product
  • Share your changes: no

A summary, not legal advice: the LICENSE file is what applies.

Getting Started

Install with pip and connect to a database:

pip install -U pgcli
pgcli [database_name]

See the README for connection options and installation details.

Alternatives

  • ZeQLplus: ZeQLplus is a SQLite terminal browser, while pgcli is a PostgreSQL client with context-aware SQL completion and syntax highlighting.
ProjectLanguageLicenseStarsStatus
pgcliPythonBSD-3-Clause13.4kActive
ZeQLplusVMIT337Inactive

Considerations

The project is active, with regular recent commits and releases, and its contributor base is not concentrated in one person. Issue handling is slower than pull-request merging: the measured median time to close an issue is substantially longer than a year, so teams should factor that into expectations for issue resolution. pgcli requires Python 3.10 or newer, and connecting to a PostgreSQL database is central to its use. Its BSD-3-Clause license permits broad reuse, subject to the license terms. The README also explicitly limits its psql backslash-command support to a primitive subset.

Found this useful?

Share it with someone who would like pgcli.

Comparisons