Skip to content
Latchkey

pgcli: Usage, Options & Common CI Errors

pgcli is a Postgres CLI with autocompletion and syntax highlighting.

pgcli is a friendlier psql for local work, occasionally used in CI for its CSV output. The catch is that it is a Python package (not bundled with Postgres) and is built for interactive TTYs.

What it does

pgcli connects to PostgreSQL like psql but adds smart autocompletion, syntax highlighting, and nicer table rendering. It accepts the same connection URLs and can run a single command non-interactively with -c.

Common usage

Terminal
pip install pgcli
pgcli postgresql://postgres:secret@localhost:5432/app
pgcli -h localhost -U postgres -d app
pgcli postgresql://postgres:secret@localhost/app -c 'SELECT 1'
pgcli --csv -h localhost -U postgres -d app -c 'SELECT * FROM t'

Options

ItemWhat it does
postgresql://... URLConnection string (same as psql)
-h / -U / -dHost / user / database
-c "SQL"Run one command and exit
--csvEmit CSV instead of a table
--less-chattyReduce informational output

Common errors in CI

pgcli: command not found - it is a pip package, not part of postgresql-client; pip install pgcli first (or just use psql, which is preinstalled). pgcli is designed for an interactive terminal, so without a TTY some features warn or misbehave; for scripted, parseable output prefer psql -t -A or pgcli --csv -c. Connection/auth errors are identical to psql (PGPASSWORD, host/port, password authentication failed).

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →