Databases 4 min read

Master MyCLI: A Powerful Python‑Based Interactive Database Client

This guide introduces MyCLI, a Python‑driven interactive command‑line client for databases, covering its key features, installation methods, configuration steps, connection commands, query execution, syntax‑highlighting options, and practical usage examples.

Open Source Tech Hub
Open Source Tech Hub
Open Source Tech Hub
Master MyCLI: A Powerful Python‑Based Interactive Database Client

Introduction

MyCLI is a Python‑written command‑line tool that uses the prompt_toolkit library to build interactive CLI applications for interacting with various databases. It sits on Python’s DB‑API and provides shortcuts, auto‑completion, syntax highlighting, history, and export features.

Features

Auto‑completion : suggests tables, column names, keywords.

Syntax highlighting : colors SQL statements.

History : records all commands for reuse.

Keyboard shortcuts : e.g., Ctrl+R to search history, Ctrl+W to delete previous word.

Export : results can be saved as CSV, JSON, or HTML.

Installation and Configuration

Installation

apt-get install mycli

Or install via Python’s package manager:

pip install mycli

Configuration

Before using MyCLI you must provide connection details, either on the command line or in a configuration file. The first run creates ~/.myclirc. MyCLI also reads the [client] section from MySQL’s config file.

Database Management

Connecting to a Database

mycli -h hostname -u username -p password -P port -D database

Example output shows MySQL version, MyCLI version, and links to the home page and bug tracker.

Docker container connection
docker exec -it dnmp-mysql sh -c "export LANG=C.UTF-8 && mycli -h 127.0.0.1 -p123456"

Executing SQL Queries

After a successful connection, type SQL statements and press Enter; results are displayed in a table.

Syntax Highlighting

If you get tired of the default theme, MyCLI provides several built‑in color schemes.

Open MyCLI configuration file
vim ~/.myclirc
Official color theme repository: https://www.mycli.net/syntax

Locate the syntax_style = default line and change it to the desired theme.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

PythonSQLcommand-lineauto-completionMyCLIDatabase clientprompt_toolkit
Open Source Tech Hub
Written by

Open Source Tech Hub

Sharing cutting-edge internet technologies and practical AI resources.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.