gitmyhub

mycli

Python ★ 12k updated 14h ago

A Terminal Client for MySQL with AutoCompletion and Syntax Highlighting.

A smarter MySQL terminal client that auto-completes SQL keywords, table names, and column names as you type, and adds syntax highlighting and query history search to your database sessions.

PythonMySQLsetup: easycomplexity 2/5

mycli is a command-line tool for working with MySQL databases. MySQL is a widely used database system, and the standard way to interact with it from a terminal is through the official mysql client, which is functional but minimal. mycli replaces that experience with something more helpful: as you type a query, it suggests completions for SQL keywords, table names, column names, and function names based on what it knows about your database.

The autocomplete is context-aware. If you type a SELECT statement and then a FROM clause, the suggestions will show table names. If you continue to a WHERE clause, they switch to column names from the table you already chose. This reduces the need to memorize exact names or check a separate schema reference while writing queries.

Beyond autocomplete, the tool colors SQL syntax to make queries easier to read, formats query results as clean tables with colors, and supports searching through previous queries using a fuzzy search tool. You can save frequently used queries under short aliases and call them back by name, optionally with parameters. Every query can optionally be logged to a file for later reference.

The tool also supports SSL connections to databases, multiline queries, and the ability to pipe query output to other command-line tools using shell-style redirect operators. A recent addition lets you query language models using your database schema as context.

Installation is available through pip on any platform, Homebrew on macOS, and the package managers of several Linux distributions including Debian, Ubuntu, Fedora, and Arch. It requires Python 3.10 or newer and is primarily tested on macOS and Linux. Windows is not officially supported but may work through the Windows Subsystem for Linux.

Where it fits