mycli README

The project's README from github.com/dbcli/mycli. As one markdown file: README.md.

mycli

Build Status License

Rich MySQL terminal client with auto-completion, syntax highlighting, and dataframes.

Homepage: https://mycli.net

Documentation: https://mycli.net/docs

Completion

CompletionGif

Mycli is known to be compatible with

Postgres equivalent

Release 2.x

Release 2.0.0 has breaking changes!

Quick Start

If you already know how to install Python packages, then you can install mycli via pip. This package is always up to date.

You might need sudo on Linux.

pip install --upgrade 'mycli[all]'

or, on macOS (pygments is optional but recommended):

brew update && brew install mycli pygments

or, on Debian or Ubuntu (fzf and pygments are optional but recommended):

sudo apt-get install mycli fzf python3-pygments

Usage

See

mycli --help

Features

Mycli creates a config file ~/.myclirc on the first run; you can use the options in that file to configure the above features, and more.

Some features are only exposed as key bindings.

Contributions

If you're interested in contributing to this project, first of all we would like to extend our heartfelt gratitude. We've written a small doc to describe how to get mycli running in a development setup.

https://github.com/dbcli/mycli/blob/main/CONTRIBUTING.md

Additional Install Instructions

Shell Completions

If installed via Homebrew, shell completions may already be configured.

Otherwise, to configure shell completions for the current session, execute a command like this:

eval "$(mycli --completions SHELL)"

replacing SHELL with bash, zsh, or fish, depending on your choice of shell.

To permanently install shell completions, the above command may be added to your ~/.bashrc, ~/.zshrc, or ~/.config/fish/config.fish. To speed up login time, the output of mycli --completions SHELL may be saved to a file and loaded with source.

Alternative Install Methods

These are some alternative ways to install mycli that are not managed by our team but provided by OS package maintainers. OS packages could be considerably out of date.

If present, the fzf package can be used for fuzzy history search, and as an output "explorer" with the \x special command. pygmentize can be used for syntax highlighting within the fuzzy history search. The less package is also expected, but almost always already installed.

Arch, Manjaro

You can install the mycli package available in the AUR. fzf and python-pygments are optional but recommended:

yay -S mycli fzf python-pygments

Debian, Ubuntu

On Debian and Ubuntu distributions, you can easily install the mycli package using apt. The fzf and python3-pygments packages are optional but recommended:

sudo apt-get install mycli fzf python3-pygments

Fedora

Fedora has a package available for mycli; install it using dnf. The fzf and python-pygments packages are optional but recommended:

sudo dnf install mycli fzf python-pygments

Docker

The images on Dockerhub are out of date. ghcr.io is preferred. Example:

docker run --pull=always -it ghcr.io/dbcli/mycli:latest

Windows

Option 1: Native Windows

Install the less pager, for example by scoop install less.

Install the fzf fuzzy finder, for example by scoop install fzf.

Follow the instructions on this blog post: https://web.archive.org/web/20221006045208/https://www.codewall.co.uk/installing-using-mycli-on-windows/

The libraries used in mycli are Windows-compatible, but there are known limitations according to the test suite. The basics work without any modifications, but this configuration isn't supported software at this time.

PRs to address shortcomings on Windows would be welcome!

Option 2: WSL

Mycli is more compatible with WSL than with native Windows, though still not 100% perfect. This is a good option for using mycli on Windows.

With WSL, you are probably using an Ubuntu distribution, in which case recommended dependencies can be installed by

sudo apt-get install fzf python3-pygments

and mycli can be installed by apt-get or by pip (recommended):

pip install --upgrade 'mycli[all]'

PRs to complete WSL support would be welcome!

Thanks

This project was funded through Kickstarter. Our thanks to the backers who supported the project.

A special thanks to Jonathan Slenders for creating Python Prompt Toolkit, which is quite literally the backbone library, that made this app possible. Jonathan has also provided valuable feedback and support during the development of this app.

Click is used for command line option parsing and printing error messages.

Thanks to PyMysql for a pure Python adapter to MySQL databases.

Compatibility

Mycli is tested on macOS (full), Linux (full), Windows (partial), and WSL (partial), and requires Python 3.10 or better.

To connect to MySQL versions earlier than 5.5, you may need to set the following in ~/.myclirc:

[connection]
# character set for connections without --charset being set at the CLI
default_character_set = utf8

or use --charset=utf8 when invoking mycli.

Configuration and Usage

For more information on using and configuring mycli, check out our documentation.

Common topics include:

mycli (dbcli/mycli)

Searching Database…

12K ·GitHub
这是什么?mycli 是一个用于 MySQL 系列数据库的命令行客户端,在原生 mysql 命令行的基础上增加了自动补全、语法高亮以及内置的数据框(dataframe)处理工具。
mycli 和直接使用原生 mysql 命令行有什么不同?它新增了上下文感知的自动补全,输入时可以补全表名和列名;支持 Pygments 语法高亮、多行查询、保存常用查询,还可以用 Polars 对查询结果做数据框变换。
我该如何安装 mycli?运行 pip install mycli(在 Linux 上可能需要 sudo)。也可以通过 Homebrew、apt、dnf、AUR 安装系统软件包,或使用托管在 ghcr.io 上的 Docker 镜像。
mycli 需要什么版本的 Python,还需要哪些额外工具?需要 Python 3.10 或更高版本。Pygments 和 fzf 是可选的,但推荐安装:Pygments 提供语法高亮,fzf 支持模糊历史搜索和输出结果浏览器。
mycli 在 Windows 上能完全正常使用吗?不能完全正常使用。原生 Windows 的支持只是部分的,测试套件还存在已知缺口;macOS 和 Linux 则完全支持。WSL 的体验比原生 Windows 好,但仍不完美。
/llm 命令有什么用?它允许你在 mycli 提示符中调用大语言模型(LLM),并自动把从数据库架构中提取的上下文提供给模型,帮助生成 SQL。
mycli 能处理数据框和 Parquet 文件吗?可以。mycli 支持通过 .| 运算符对数据框进行 Polars 变换和绘图,也可以用 .> 把结果保存为 Parquet 文件。
mycli 把我的设置存放在哪里?首次运行时,它会在 ~/.myclirc 创建一个配置文件,你可以在其中调整自动补全、日志、SSL 以及其他行为。
mycli 能安全地保存我的数据库密码吗?可以。它可以把密码保存在系统密钥环中,而不是以明文形式存放在配置文件里。
What are similar projects?usql, dbx, sqlit, TablePro, dolt, beekeeper-studio, tusk, GoNavi
Creator
dbcli
Size
40.5 MB
Stars
12K
Age
11y
Commits · 90 Days