LinuxCommandLibrary

pgcli

Connect to PostgreSQL with autocompletion and syntax highlighting

SYNOPSIS

pgcli [options] [database_name]

PARAMETERS

--help
    Display help message and exit.

-h, --host HOST
    Database server host or socket directory (default: localhost).

-p, --port PORT
    Database server port (default: 5432).

-U, --username USERNAME
    Database username.

-d, --dbname DBNAME
    Database name to connect to.

--ssl
    Use SSL encryption for the connection.

--version
    Show program's version number and exit.

-w, --password
    Force password prompt.

-W, --no-password
    Never prompt for password.

-v, --verbose
    Increase verbosity.

-c, --command COMMAND
    Run only single command (SQL) and exit.

--list-drivers
    List supported drivers

--list-dbs
    List available databases.

--config-file PATH
    Path to custom config file.

DESCRIPTION

pgcli is a command-line interface for PostgreSQL databases that provides autocompletion, syntax highlighting, and smart suggestions. It aims to improve the user experience when interacting with PostgreSQL from the terminal.

Unlike the standard psql client, pgcli suggests SQL keywords and table names as you type, making query construction faster and less error-prone. It supports multiple databases, including PostgreSQL, and offers features such as displaying query execution times, highlighting syntax errors, and automatic formatting of query results.

pgcli is especially useful for developers and database administrators who frequently interact with PostgreSQL from the command line and value productivity and convenience.
It also saves your query history and it could be used to query other SQL databases with different drivers.

CONFIGURATION

pgcli can be configured using a config file located in ~/.config/pgcli/config. This file allows you to customize settings such as the autocompletion behavior, key bindings, and color scheme. You can also set environment variables to configure the connection, such as PGHOST, PGPORT, PGUSER and PGDATABASE.

AUTOCOMPLETION

The autocompletion feature of pgcli relies on introspecting the database schema to suggest relevant keywords, table names, column names, and functions as you type. This significantly speeds up query construction and reduces the likelihood of syntax errors.

HISTORY

pgcli was developed to address the limitations of the standard psql client, particularly the lack of autocompletion and syntax highlighting. It gained popularity among PostgreSQL users seeking a more interactive and user-friendly command-line experience. The project continues to be actively developed and maintained, with contributions from the open-source community.
First version was created around 2014.

SEE ALSO

psql(1)

Copied to clipboard