{"name":"pgcli: An Enhanced PostgreSQL Command-Line Interface","description":"pgcli is a powerful command-line interface for PostgreSQL, designed to enhance productivity. It offers intelligent autocompletion and vibrant syntax highlighting, making database interactions more intuitive. This Python-based tool provides a superior alternative to the standard `psql` client for developers and DBAs.","github":"https://github.com/dbcli/pgcli","url":"https://osrepos.com/repo/dbcli-pgcli","source":"osrepos.com","sourceDescription":"This repository profile is provided by osrepos.com, an open source repository discovery platform.","repositoryProfile":"https://osrepos.com/repo/dbcli-pgcli","generatedFor":"open source discovery and AI-assisted research","markdown":"https://osrepos.com/repo/dbcli-pgcli.md","json":"https://osrepos.com/repo/dbcli-pgcli.json","topics":["database","postgres","postgresql","psql","python","CLI Tool","Developer Tools"],"keywords":["database","postgres","postgresql","psql","python","CLI Tool","Developer Tools"],"stars":null,"summary":"pgcli is a powerful command-line interface for PostgreSQL, designed to enhance productivity. It offers intelligent autocompletion and vibrant syntax highlighting, making database interactions more intuitive. This Python-based tool provides a superior alternative to the standard `psql` client for developers and DBAs.","content":"## Introduction\n\npgcli is an open-source command-line interface (CLI) for PostgreSQL databases, developed by dbcli. It stands out by providing a rich interactive experience with features like intelligent autocompletion and syntax highlighting. This Python-based tool aims to make working with PostgreSQL from the terminal more efficient and enjoyable for developers and database administrators.\n\n## Installation\n\nInstalling pgcli is straightforward across various platforms. Here are some common methods:\n\n*   **Using pip (Python package manager):**\n    bash\n    $ pip install -U pgcli\n    \n*   **On Debian-based Linux (e.g., Ubuntu, Mint):**\n    bash\n    $ sudo apt-get install pgcli\n    \n*   **On macOS (using Homebrew):**\n    bash\n    $ brew install pgcli\n    \n*   **Using pipx (for isolated environments):**\n    bash\n    $ pipx install pgcli\n    \n*   **Using uvx (install on the fly):**\n    bash\n    $ uvx pgcli\n    \n*   **Via Docker:**\n    bash\n    $ docker build -t pgcli .\n    $ docker run --rm -ti --net host pgcli pgcli -h localhost foo\n    \n\nFor more detailed instructions, including setting up Python environments, please refer to the [official installation guide](https://github.com/dbcli/pgcli#detailed-installation-instructions).\n\n## Examples\n\nConnecting to your PostgreSQL database with pgcli is simple. You can specify the database name directly or use a full connection string:\n\n*   **Connect to a local database:**\n    bash\n    $ pgcli local_database\n    \n*   **Connect using a comprehensive connection string:**\n    bash\n    $ pgcli postgres://amjith:pa$$w0rd@example.com:5432/app_db?sslmode=verify-ca&sslrootcert=/myrootcert\n    \n\npgcli also supports many environment variables similar to `psql` (e.g., `PGHOST`, `PGPORT`, `PGUSER`, `PGPASSWORD`, `PGDATABASE`) and SSL-related environment variables for secure connections.\n\nTo explore all available options, use the `--help` command:\n\nbash\n$ pgcli --help\n\nUsage: pgcli [OPTIONS] [DBNAME] [USERNAME]\n\nOptions:\n  -h, --host TEXT            Host address of the postgres database.\n  -p, --port INTEGER         Port number at which the postgres instance is\n                             listening.\n  -U, --username TEXT        Username to connect to the postgres database.\n  -u, --user TEXT            Username to connect to the postgres database.\n  -W, --password             Force password prompt.\n  -w, --no-password          Never prompt for password.\n  --single-connection        Do not use a separate connection for completions.\n  -v, --version              Version of pgcli.\n  -d, --dbname TEXT          database name to connect to.\n  --pgclirc FILE             Location of pgclirc file.\n  -D, --dsn TEXT             Use DSN configured into the [alias_dsn] section\n                             of pgclirc file.\n  --list-dsn                 list of DSN configured into the [alias_dsn]\n                             section of pgclirc file.\n  --row-limit INTEGER        Set threshold for row limit prompt. Use 0 to\n                             disable prompt.\n  --less-chatty              Skip intro on startup and goodbye on exit.\n  --prompt TEXT              Prompt format (Default: \"\\u@\\h:\\d> \").\n  --prompt-dsn TEXT          Prompt format for connections using DSN aliases\n                             (Default: \"\\u@\\h:\\d> \").\n  -l, --list                 list available databases, then exit.\n  --auto-vertical-output     Automatically switch to vertical output mode if\n                             the result is wider than the terminal width.\n  --warn [all|moderate|off]  Warn before running a destructive query.\n  --help                     Show this message and exit.\n\n\n## Why Use pgcli?\n\npgcli offers several compelling features that make it a superior choice for interacting with PostgreSQL databases from the command line:\n\n*   **Intelligent Autocompletion:** It auto-completes SQL keywords, table names, and column names as you type, significantly speeding up query writing.\n*   **Context-Sensitive Smart-Completion:** For example, `SELECT * FROM <tab>` will only suggest table names, while `SELECT * FROM users WHERE <tab>` will suggest column names from the `users` table.\n*   **Syntax Highlighting:** Queries are beautifully highlighted using Pygments, improving readability and helping to spot errors.\n*   **Pretty Printing:** Tabular data results are formatted cleanly, making it easier to read and analyze query outputs.\n*   **psql Back-Slash Commands:** Supports primitive `psql` back-slash commands for familiar operations.\n*   **IPython Integration:** Can be run within an IPython console, allowing you to iterate on queries and retrieve results directly into your IPython workspace.\n\n## Links\n\n*   **GitHub Repository:** [https://github.com/dbcli/pgcli](https://github.com/dbcli/pgcli){:target=\"_blank\"}\n*   **Official Homepage:** [http://pgcli.com](http://pgcli.com){:target=\"_blank\"}\n*   **MySQL Equivalent (mycli):** [http://mycli.net](http://mycli.net){:target=\"_blank\"}\n*   **Detailed Installation Instructions:** [https://github.com/dbcli/pgcli#detailed-installation-instructions](https://github.com/dbcli/pgcli#detailed-installation-instructions){:target=\"_blank\"}","metrics":{"detailViews":3,"githubClicks":3},"dates":{"published":null,"modified":"2026-03-20T01:11:32.000Z"}}