MySQL命令行客户端:mycli

dgbm 9年前

一个MySQL的命令行客户端,具有自动完成和语法高亮的功能。

Completion CompletionGif

Postgres 的命令行: http://pgcli.com

快速入门

假如你已经知道如何安装 python 包,你就可以通过pip安装它:

You might need sudo on linux.

$ pip install mycli

or

$ brew install mycli  # Only on OS X

Check the detailed install instructions for debian packages or getting started with pip.

用法

$ mycli --help  Usage: mycli [OPTIONS] [DATABASE]    Options:    -h, --host TEXT         Host address of the database.    -P, --port TEXT         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          Force password prompt.    --pass TEXT             Password to connect to the database    -v, --version           Version of mycli.    -D, --database TEXT     Database to use.    -R, --prompt TEXT       Prompt format (Default: "\t \u@\h:\d> ")    -l, --logfile FILENAME  Log every query and its results to a file.    --help                  Show this message and exit.

Examples

$ mycli local_database    $ mycli -h localhost -u root app_db    $ mycli mysql://amjith@localhost:3306/django_poll

特性

mycliis 使用 prompt_toolkit开发

  • 输入提示当你输入SQL关键字时,包括数据库中的表格和字段
  • 使用Pygments实现语法高亮
  • 智能补全(默认启用),会提示上下文敏感的完成。

    • SELECT * FROM <tab>will only show table names.
    • SELECT * FROM users WHERE <tab>will only show column names.
  • Config file is automatically created at~/.myclircat first launch.

  • Pretty prints tabular data.

项目主页:http://www.open-open.com/lib/view/home/1438317378472