Skip to main content

AI-Agent-friendly database CLI for AnalyticDB MySQL

Project description

English | 简体中文

analyticdb-mysql-cli

AI-Agent-friendly database CLI for AnalyticDB MySQL. Default JSON output, stateless invocations, and a consistent error format make it easy for agents to run SQL and inspect schema reliably.

AnalyticDB MySQL is Alibaba Cloud's cloud-native data warehouse product.

Why analyticdb-mysql-cli

  • Agent-friendly: Any agent that can run shell commands can use analyticdb-mysql-cli via the adbmysql-cli command (the analyticdb-mysql-cli command is the same entry point, useful for which analyticdb-mysql-cli–style checks); output is JSON by default, and the adbmysql-cli ai-guide command provides a self-description of analyticdb-mysql-cli usage for agents.
  • Safety: Row limits, write guards, and masking reduce risk when agents or scripts operate on live data.
  • Unified interface: Execute SQL via CLI, without interactive prompts or session state.

Features

  • JSON by default: All commands emit structured JSON; use --format table|csv|jsonl for human-readable output.
  • Row limits: LIMIT required when result exceeds 1000 rows.
  • Write safeguards: Writes require --write; DELETE/UPDATE without WHERE are disallowed.
  • Sensitive-field masking: Columns such as phone, email, password, id_card are auto-masked in query results.
  • Operation history: All commands are logged to ~/.adbmysql/sql-history.jsonl; for SQL execution, the SQL text is logged with sensitive literals redacted.

Requirements

  • Python 3.11+
  • AnalyticDB MySQL instance (MySQL-protocol–compatible)

Installation

From PyPI:

uv tool install analyticdb-mysql-cli

From local source:

cd analyticdb-mysql-cli
uv tool install .

After installation, the adbmysql-cli command is available. The same program is also installed as analyticdb-mysql-cli (e.g. for tooling that probes the binary name matching the PyPI package).

Connection

To connect to an AnalyticDB MySQL instance, create a global config file:

mkdir -p ~/.adbmysql
# Remote
echo 'ADBMYSQL_DSN="mysql://user:pass@host:port/database"' > ~/.adbmysql/config.env

Also supports --dsn CLI flag, ADBMYSQL_DSN environment variable, and project .env files, in decreasing priority.

Common commands

Command Description
adbmysql-cli status Connection status and version
adbmysql-cli schema tables List all tables
adbmysql-cli schema describe <table> Table structure (columns, types, indexes)
adbmysql-cli schema dump Output DDL for all tables (to stdout)
adbmysql-cli table profile <table> Table data profile (row count, nulls, distinct, min/max, candidate JOIN keys and time columns)
adbmysql-cli sql "<stmt>" Execute SQL (read-only by default; use --write for writes; --with-schema adds table schema; --no-truncate keeps large fields intact)
adbmysql-cli relations infer [--table <t>] Infer JOIN relationships between tables
adbmysql-cli ai-guide Print structured guide for AI agents (JSON)

Option order

--dsn and --format are global options and must appear before the subcommand:

adbmysql-cli --format table sql "SELECT * FROM t LIMIT 5"
adbmysql-cli --dsn "mysql://root:@127.0.0.1:3306/test" schema tables

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

analyticdb_mysql_cli-0.1.0.tar.gz (22.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

analyticdb_mysql_cli-0.1.0-py3-none-any.whl (22.9 kB view details)

Uploaded Python 3

File details

Details for the file analyticdb_mysql_cli-0.1.0.tar.gz.

File metadata

  • Download URL: analyticdb_mysql_cli-0.1.0.tar.gz
  • Upload date:
  • Size: 22.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for analyticdb_mysql_cli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 cd92281cc2642a5d837d06ccb623f28c3e39e6c2d7aa86323ff05a1b5238f363
MD5 fb3a076eaffe7c85733bc29b91f115e1
BLAKE2b-256 8c5f49e09df831842b757689d47298fddf59284240fb70cba04283836bc72ddb

See more details on using hashes here.

File details

Details for the file analyticdb_mysql_cli-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for analyticdb_mysql_cli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bc1b331d52d046186f6a219e44827572a64d30338ce62be9c3eceaf8aaa50e6e
MD5 3410ba7de906d811488413e1ccb3eeea
BLAKE2b-256 2da47612e3b7f159ce737b95b3d15898f524d0d0a388a14f7a668622fcf7668f

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page