PG增强版命令行客户端之pgcli
简介
源码:https://github.com/dbcli/pgcli
Pgcli 是 PostgreSQL 数据库的命令行接口,支持自动完成和语法高亮。
安装
1 2 3 4 5 6 | export LD_LIBRARY_PATH=/usr/pgsql-13/lib:$LD_LIBRARY_PATH export PATH=$PATH:/usr/pgsql-13/bin yum install -y python3 python3-devel python3-pip python3-setuptools python3-psycopg2 libpq-dev pip3 install psycopg2 psycopg2-binary pip3 install pgcli pgcli --help |
帮助:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 | [root@docker35 ~]# pgcli --help Usage: pgcli [OPTIONS] [DBNAME] [USERNAME] Options: -h, --host TEXT Host address of the postgres database. -p, --port INTEGER Port number at which the postgres instance is listening. -U, --username TEXT Username to connect to the postgres database. -u, --user TEXT Username to connect to the postgres database. -W, --password Force password prompt. -w, --no-password Never prompt for password. --single-connection Do not use a separate connection for completions. -v, --version Version of pgcli. -d, --dbname TEXT database name to connect to. --pgclirc FILE Location of pgclirc file. -D, --dsn TEXT Use DSN configured into the [alias_dsn] section of pgclirc file. --list-dsn list of DSN configured into the [alias_dsn] section of pgclirc file. --row-limit INTEGER Set threshold for row limit prompt. Use 0 to disable prompt. --less-chatty Skip intro on startup and goodbye on exit. --prompt TEXT Prompt format (Default: "\u@\h:\d> "). --prompt-dsn TEXT Prompt format for connections using DSN aliases (Default: "\u@\h:\d> "). -l, --list list available databases, then exit. --auto-vertical-output Automatically switch to vertical output mode if the result is wider than the terminal width. --warn [all|moderate|off] Warn before running a destructive query. --help Show this message and exit. |
Examples
1 2 3 4 5 | $ pgcli local_database $ pgcli postgres://amjith:passw0rd@example.com:5432/app_db $ pgcli -h localhost -p 5432 -U amjith app_db |
note: While using @
or special symbol in password, do encode and quote it.
1 2 3 | $ pgcli 'postgresql://amjith:%40postgres@localhost:5432/app_db' $ pgcli -h localhost -U amjith -W '@postgres' -d app_db |