pgcli CLI
pgcli is a terminal PostgreSQL client with SQL-aware suggestions: tables after FROM and columns after WHERE.
- 13,434 ★ on the repository
- Last commit
- BSD-3-Clause
Extended access
Why this level
- The client executes SQL with the connected role’s permissions, including data changes when allowed.
Install
In your terminal, with SkillFoxx CLI
npx skillfoxx add cli/pgcliDetects the agents on your machine, shows the access level and pins the version.
Other ways to install
Access and checks
How we reviewExtended accessThe tool runs code or makes network calls and only reads external data.
- The client executes SQL with the connected role’s permissions, including data changes when allowed.
This is third-party code. Review the repository files before installing.
What it does
pgcli is a terminal client that opens an interactive PostgreSQL SQL session with schema-aware suggestions. Completion proposes relevant tables and columns while highlighting helps inspect the query before execution. Results appear as tables. It supports familiar psql connection parameters and environment variables, plus named connections. An agent can prepare a query for review in the terminal session.
Who it is for. PostgreSQL analysts exploring tables and writing queries interactively in a terminal.
Good fit when
- An unfamiliar schema needs name completion while writing SQL.
- A long query benefits from syntax highlighting before execution.
- A wide result needs vertical display for readability.
- Work alternates between several configured databases.
Not a fit when
- You need a database server rather than a client.
- A workflow depends on complete psql meta-command compatibility.
- The account has write rights even though the task is read-only.
Example request
Prepare pgcli access to the test database with read-only rights and a schema inspection query. Do not embed the password in the command.Limitations
A suitable Python environment and PostgreSQL access with valid credentials are required. psql meta-command support is limited, so verify advanced workflows separately. Completion normally uses an additional connection. `--single-connection` disables that separate completion connection. Destructive-query warnings are configurable and do not replace a restricted database role or checking the active connection before execution.
How to disable. Exit with Ctrl-D and uninstall pgcli through its package manager. Remove saved connection configuration separately.
FAQ
How do I open a local database?
Run `pgcli local_database` with your database name and inspect the session prompt.
Where do suggestions come from?
The client uses SQL context and the connected schema. It shows tables after FROM and columns after WHERE.
Can I use libpq environment variables?
Yes. `PGHOST`, `PGPORT` and other connection variables are supported. Inspect settings without exposing the password.
Where is configuration stored?
The first run creates `~/.config/pgcli/config` with option descriptions.
How do I prompt for a password?
Use `-W` to request the password while connecting, keeping its value out of command-line arguments.
Discussion
No questions or reviews yet.
Related
CLI toolsAn MCP server and skills from TigerData that help agents write PostgreSQL schemas and queries from current docs and practices
dblab is a terminal SQL client with saved connection profiles and optional password storage in the operating system keyring.
An MCP server for PostgreSQL with several databases at once, table descriptions from the catalog, PostGIS and pgvector hints and query plans
The SQL client combines terminal database browsing with batch queries for agents using named connections and JSON results.
Postgres Professional utility for PostgreSQL backup and recovery with incremental backups and PITR
vi-sql is a terminal SQL client with a built-in MCP server: the agent sees the schema and drafts queries straight in your editor
README in short
The SQL session prompt can be customized for your connections. A separate extension integrates the client with IPython.