[转帖]数据库命令行工具USQL、mycli、litecli、pgcli

数据库,命令行,工具,usql,mycli,litecli,pgcli · 浏览次数 : 0

小编点评

**USQL** 是一个使用 Go 语言开发的支持 SQL/NoSQL 数据库的通用命令行工具,目前最新版本是usql 0.7.0。 **主要功能:** * 支持多种主流的数据库软件,包括 PostgreSQL、MySQL、Oracle Database、SQLite3、Microsoft SQL Server 以及许多其它的数据库(包括 NoSQL 和非关系型数据库)。 * 支持 SQL 语句的高亮和自动补全功能。 * 支持数据库连接设置。 * 提供多种输出选项,例如表、CSV、JSON 和调试信息。 * 允许自定义输出格式。 * 提供数据库连接设置。 **安装和使用:** 1. 安装:使用 pip 或源代码安装: ``` pip install usql ``` 2. 获取用户名和密码: - 在您的 MySQL 中运行: ```sql SELECT username, password FROM mysql.user; ``` - 从 `postgresql.conf` 中获取用户名和密码。 3. 连接数据库: - 使用以下命令连接到数据库: ``` usql -U username -P password -d database_name ``` - 替换 `username`、`password` 和 `database_name` 为您的实际值。 4. 使用命令行选项设置选项: - 使用 `-h`、`-p`、`-U`、`-W` 和 `-v` 等选项设置选项。 5. 使用其他选项: - 使用 `-t` 设置输出格式。 - 使用 `-c` 设置分页数量。 **示例命令:** ``` # 连接到 MySQL 数据库 usql -U rootPassword:mysql 5.5.53mycli 1.19.0Chat: # 连接到 PostgreSQL 数据库 usql -U postgresUsername -P postgresPassword -d database_name # 显示查询结果 SELECT * FROM table_name; # 设置输出格式为 JSON usql -v -t JSON -o table_name.json table_data; ``` **其他资源:** * 官方网站:usql.dev * GitHub 仓库:github.com/dbcli/usql * 文档:usql 文档

正文

https://www.cnblogs.com/-wenli/p/11239042.html

 

 

USQL

USQL 是一款使用 Go 语言开发的支持 SQL/NoSQL 数据库的通用命令行工具,它支持多种主流的数据库软件,目前最新版本是usql 0.7.0。比如 PostgreSQL、MySQL、Oracle Database、SQLite3、Microsoft SQL Server 以及许多其它的数据库(包括 NoSQL 和非关系型数据库)。

USQL 的灵感来自 PostgreSQL 的 PSQL,USQL 支持大多数 PSQL 的核心特性,比如:设置变量、反引号参数。并具有 PSQL 不支持的其它功能,如语法高亮、基于上下文的自动补全和多数据库支持等。

USQL项目地址

安装 USQL

由于 USQL 使用 Go 语言开发,具备了良好的Linux、Windows等跨平台特性。USQL 安装非常简单,官方也提供二进制、Homebrew、Scoop等多种安装方式。这里我们就使用最具通用性的二进制方式安装,以 Linux 平台为例:

$ wget https://github.com/xo/usql/releases/download/v0.7.0/usql-0.7.0-linux-amd64.tar.bz2

$ tar xjvf usql-0.7.0-linux-amd64.tar.bz2

$ sudo mv usql /usr/local/bin

如果你使用其它平台,可根据实际情况在官方下载页面下载对应版本。

USQL 用法

USQL:支持SQL/NoSQL数据库的通用命令行工具

 

 

mycli

mycli 是基于MySQL的命令行工具,直接使用 pip install mycli 安装,
具体介绍见 https://github.com/dbcli/mycli

复制代码
$ mycli --help
Usage: mycli [OPTIONS] [DATABASE]

  A MySQL terminal client with auto-completion and syntax highlighting.

  Examples:
    - mycli my_database
    - mycli -u my_user -h my_host.com my_database
    - mycli mysql://my_user@my_host.com:3306/my_database

Options:
  -h, --host TEXT               Host address of the database.
  -P, --port INTEGER            Port number to use for connection. Honors
                                $MYSQL_TCP_PORT.
  -u, --user TEXT               User name to connect to the database.
  -S, --socket TEXT             The socket file to use for connection.
  -p, --password TEXT           Password to connect to the database.
  --pass TEXT                   Password to connect to the database.
  --ssh-user TEXT               User name to connect to ssh server.
  --ssh-host TEXT               Host name to connect to ssh server.
  --ssh-port INTEGER            Port to connect to ssh server.
  --ssh-password TEXT           Password to connect to ssh server.
  --ssh-key-filename TEXT       Private key filename (identify file) for the
                                ssh connection.
  --ssl-ca PATH                 CA file in PEM format.
  --ssl-capath TEXT             CA directory.
  --ssl-cert PATH               X509 cert in PEM format.
  --ssl-key PATH                X509 key in PEM format.
  --ssl-cipher TEXT             SSL cipher to use.
  --ssl-verify-server-cert      Verify server's "Common Name" in its cert
                                against hostname used when connecting. This
                                option is disabled by default.
  -V, --version                 Output mycli's version.
  -v, --verbose                 Verbose output.
  -D, --database TEXT           Database to use.
  -d, --dsn TEXT                Use DSN configured into the [alias_dsn]
                                section of myclirc file.
  --list-dsn                    list of DSN configured into the [alias_dsn]
                                section of myclirc file.
  -R, --prompt TEXT             Prompt format (Default: "\t \u@\h:\d> ").
  -l, --logfile FILENAME        Log every query and its results to a file.
  --defaults-group-suffix TEXT  Read MySQL config groups with the specified
                                suffix.
  --defaults-file PATH          Only read MySQL options from the given file.
  --myclirc PATH                Location of myclirc file.
  --auto-vertical-output        Automatically switch to vertical output mode
                                if the result is wider than the terminal
                                width.
  -t, --table                   Display batch output in table format.
  --csv                         Display batch output in CSV format.
  --warn / --no-warn            Warn before running a destructive query.
  --local-infile BOOLEAN        Enable/disable LOAD DATA LOCAL INFILE.
  --login-path TEXT             Read this path from the login file.
  -e, --execute TEXT            Execute command and quit.
  --help                        Show this message and exit.

λ mycli -u root
Password:
mysql 5.5.53
mycli 1.19.0
Chat: https://gitter.im/dbcli/mycli
Mail: https://groups.google.com/forum/#!forum/mycli-users
Home: http://mycli.net
Thanks to the contributor - Jialong Liu
mysql root@localhost:(none)> show data
                                       databases
                                       create database
复制代码

注:进入MySQL命令行后如果想执行Linux命令怎么办,先退出执行然后再登录MySQL?麻烦,其实可以直接用system。

复制代码
mysql> system pwd
/root
mysql> system ll
sh: ll: command not found
mysql> system ls -al
total 40160
dr-xr-x---.   39 root     root         4096 Jul 10 14:47 .
dr-xr-xr-x.   29 root     root         4096 May  5 18:55 ..
复制代码

 

litecli

litecli 是基于 sqlite 的命令行工具,直接用 pip install -U litecli 安装,具体介绍见
https://github.com/dbcli/litecli

复制代码
$ litecli --help
Usage: litecli [OPTIONS] [DATABASE]

  A SQLite terminal client with auto-completion and syntax highlighting.

  Examples:
    - litecli lite_database

Options:
  -V, --version           Output litecli's version.
  -D, --database TEXT     Database to use.
  -R, --prompt TEXT       Prompt format (Default: "\d> ").
  -l, --logfile FILENAME  Log every query and its results to a file.
  --liteclirc PATH        Location of liteclirc file.
  --auto-vertical-output  Automatically switch to vertical output mode if the
                          result is wider than the terminal width.
  -t, --table             Display batch output in table format.
  --csv                   Display batch output in CSV format.
  --warn / --no-warn      Warn before running a destructive query.
  -e, --execute TEXT      Execute command and quit.
  --help                  Show this message and exit.

λ litecli
Version: 1.0.0
Mail: https://groups.google.com/forum/#!forum/litecli-users
Github: https://github.com/dbcli/litecli
(none)> .tables
Not connected to database.
(none)> .databases
Not connected to database.
(none)> use test
You are now connected to database "test"
Time: 0.001s
test> .tables
Time: 0.000s
test> CREATE TABLE COMPANY(
         ID INT PRIMARY KEY     NOT NULL,
         NAME           TEXT    NOT NULL,
         AGE            INT     NOT NULL,
         ADDRESS        CHAR(50),
         SALARY         REAL
      );
Query OK, 0 rows affected
Time: 0.077s
test> .tables
+---------+
| name    |
+---------+
| COMPANY |
+---------+
Time: 0.040s
复制代码

 

 

pgcli

pgcli 是一个基于 PostgreSQL 的命令行工具,支持自动补全和语法高亮,直接使用pip install -U pgcli 安装,具体介绍见 https://github.com/dbcli/pgcli

复制代码
$ pgcli --help

Usage: pgcli [OPTIONS] [DATABASE] [USERNAME]Options:

  -h, --host TEXT     Host address of the postgres database.

  -p, --port INTEGER  Port number at which the postgres instance is listening.

  -U, --user TEXT     User name to connect to the postgres database.

  -W, --password      Force password prompt.

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

  -v, --version       Version of pgcli.

  -d, --dbname TEXT   database name to connect to.

  --pgclirc TEXT      Location of pgclirc file.

  --help              Show this message and exit.
 
 

与[转帖]数据库命令行工具USQL、mycli、litecli、pgcli相似的内容:

[转帖]数据库命令行工具USQL、mycli、litecli、pgcli

https://www.cnblogs.com/-wenli/p/11239042.html USQL USQL 是一款使用 Go 语言开发的支持 SQL/NoSQL 数据库的通用命令行工具,它支持多种主流的数据库软件,目前最新版本是usql 0.7.0。比如 PostgreSQL、MySQL、Or

[转帖]USQL:支持SQL/NoSQL数据库的通用命令行工具

https://ywnz.com/linuxysjk/2342.html USQL 是一款使用 Go 语言开发的支持 SQL/NoSQL 数据库的通用命令行工具,它支持多种主流的数据库软件,目前最新版本是usql 0.7.0。比如 PostgreSQL、MySQL、Oracle Database、S

[转帖]JVM监控及诊断工具-命令行

https://www.cnblogs.com/xiaojiesir/p/15622372.html 性能指标 停顿时间(响应时间) 提交请求和返回响应之间使用的时间,一般比较关注平均响应时间 常用操作的响应时间列表: 操作 响应时间 打开一个站点 几秒 数据库查询一条记录(有索引) 十几毫秒 机械

[转帖]TIDB - 使用BR工具进行数据热备份与恢复

一、BR工具 BR 全称为 Backup & Restore,是 TiDB 分布式备份恢复的命令行工具,用于对 TiDB 集群进行数据备份和恢复。BR 只支持在 TiDB v3.1 及以上版本使用。 在前面的章节中,我们介绍了dumpling将数据导出的方式,也可以作为一种备份的方式,并且导出的数据

[转帖]TIDB - 使用BR工具进行数据热备份与恢复

一、BR工具 BR 全称为 Backup & Restore,是 TiDB 分布式备份恢复的命令行工具,用于对 TiDB 集群进行数据备份和恢复。BR 只支持在 TiDB v3.1 及以上版本使用。 在前面的章节中,我们介绍了dumpling将数据导出的方式,也可以作为一种备份的方式,并且导出的数据

[转帖]Linux下curl用法详解

https://zhuanlan.zhihu.com/p/430490147 Curl(CommandLine Uniform Resource Locator),即在命令行中利用URL进行数据或者文件传输,它是Linux下强大的http命令行工具,其功能十分强大,我们来看下帮助页面,参数非常丰富。

[转帖]【JVM】JDK命令行工具

在JDK/bin目录下我发现了许多命令行工具 这些命令有哪些作用呢,接下来我就来详细介绍一下 常用JDK命令行工具 命令名称全称用途jstatJVM Statistics Monitoring Tool用于收集Hotspot虚拟机各方面的运行数据jpsJVM Process Status Tool显

[转帖]Linux服务器上监控网络带宽的18个常用命令-2

https://www.cnblogs.com/fan-yuan/p/9231501.html 本文介绍了一些可以用来监控网络使用情况的Linux命令行工具。这些工具可以监控通过网络接口传输的数据,并测量目前哪些数据所传输的速度。入站流量和出站流量分开来显示。 这些工具使用不同的机制来制作流量报告。

[转帖]3003 - 神通数据库命令行

http://www.5ityx.com/cate100/217481.html 1、命令行连接:isql -d osrdb -P 2003 -U sysdba/szoscar55 2、后台创建库命令(中括号代表可选) 2.1 进入后台:oscar/kstore 列出库:list database

[转帖]备份VCSA内置Postgresql数据库

首先命令行远程登录到VCSA服务器,然后执行如下命令停掉VCSA的核心服务vmware-vpxd: vCenterServerAppliance:~ # service vmware-vpxd stop Stopping VMware vSphere Profile-Driven Storage S