Cette page est affichée en anglais. Une traduction française est en cours.
ConfigsApr 15, 2026·2 min de lecture

pgcli — PostgreSQL CLI with Auto-Completion and Syntax Highlighting

pgcli is a modern `psql` replacement in Python with intelligent auto-completion for tables/columns/functions, syntax highlighting, multi-line editing, and output formatting.

Prêt pour agents

Staging sûr pour cet actif

Cet actif est d'abord staged. Le prompt copié demande à l'agent d'inspecter les fichiers staged avant d'activer scripts, config MCP ou config globale.

Stage only · 17/100Policy : staging
Surface agent
Tout agent MCP/CLI
Type
CLI Tool
Installation
Stage only
Confiance
Confiance : Established
Point d'entrée
pgcli guide
Commande de staging sûr
npx -y tokrepo@latest install 44395a8b-38c4-11f1-9bc6-00163e2b0d79 --target codex

Stage les fichiers d'abord; l'activation exige la revue du README et du plan staged.

TL;DR
pgcli replaces psql with intelligent auto-completion, syntax highlighting, and multi-line editing.
§01

What it is

pgcli is a Python-based interactive command-line interface for PostgreSQL that serves as a modern replacement for psql. It adds intelligent auto-completion for table names, column names, SQL keywords, and functions, plus syntax highlighting, multi-line editing, and formatted output.

The tool targets database administrators, backend developers, and data engineers who work with PostgreSQL from the terminal and want a more productive CLI experience.

§02

How it saves time or tokens

pgcli eliminates the constant context-switching of checking table schemas before writing queries. Auto-completion surfaces column names as you type, reducing typos and the need to run \d table_name repeatedly. Syntax highlighting catches errors visually before execution.

§03

How to use

  1. Install pgcli: pip install pgcli or brew install pgcli.
  2. Connect to your database: pgcli -h localhost -U postgres -d mydb.
  3. Start typing SQL -- auto-completion and highlighting activate automatically.
§04

Example

# Install
pip install pgcli

# Connect to a local database
pgcli -h localhost -U postgres -d mydb

# Inside pgcli, auto-completion works as you type:
# SELECT u  -> suggests: users, updates, uuid_generate_v4()
# SELECT * FROM users WHERE  -> suggests column names: id, name, email

# Useful pgcli-specific commands:
# \f   - toggle formatted output
# \x   - expanded display
# \dt  - list tables
# F2   - toggle multi-line mode
§05

Related on TokRepo

§06

Common pitfalls

  • pgcli's auto-completion queries the database schema on startup. For databases with thousands of tables, this can cause a slow initial connection. Use --no-auto-complete for large schemas.
  • pgcli stores command history in ~/.config/pgcli/history. Be careful with sensitive queries in shared environments.
  • Some psql backslash commands behave slightly differently in pgcli. Check \? inside pgcli for the exact supported set.

Questions fréquentes

How does pgcli compare to psql?+

pgcli adds smart auto-completion, syntax highlighting, and multi-line editing on top of psql's functionality. psql is the official PostgreSQL client with complete feature coverage. pgcli is a drop-in replacement for interactive use but defers to psql for scripting.

Does pgcli support SSL connections?+

Yes. pgcli passes connection parameters through to the underlying psycopg library, which supports SSL. Use the same SSL flags or connection strings you would use with psql.

Can pgcli connect to remote databases?+

Yes. pgcli supports all standard PostgreSQL connection methods: host/port/user flags, connection URIs, and .pgpass files. It works with local, remote, and cloud-hosted PostgreSQL instances.

Does pgcli work with Amazon RDS or Aurora?+

Yes. pgcli connects to any PostgreSQL-compatible database, including Amazon RDS, Aurora, Google Cloud SQL, Azure Database for PostgreSQL, and Supabase.

Is pgcli safe to use in production?+

pgcli is a read/write client just like psql. It does not add any safety layer. Use the same caution you would with psql -- avoid running unreviewed queries on production databases.

Sources citées (3)

Fil de discussion

Connectez-vous pour rejoindre la discussion.
Aucun commentaire pour l'instant. Soyez le premier à partager votre avis.

Actifs similaires