Skip to main content

AI-powered CLI tool for Relation database management and analysis

Project description

RDSAI CLI

Python 3.13+ License

English | 中文


image.png

RDSAI CLI is a next-generation, AI-powered RDS CLI that transforms how you interact with the database. You describe your intent in natural language or SQL, and the AI agent performs hybrid processing of both: orchestrating diagnostic tools, analyzing execution plans, and executing queries — all without leaving your terminal. From performance troubleshooting to schema exploration, it handles the complexity so you can focus on what truly matters.

✨ Features

  • Multi-Source Connection — Connect to MySQL databases, local files (CSV, Excel), and remote data sources (HTTP/HTTPS URLs), with support for multiple files simultaneously
  • AI Assistant — Natural language queries (English/中文), optimized SQL, diagnostics, and explanations
  • Smart SQL — Auto-detects SQL vs natural language, query history, Ctrl+E for instant result explanations
  • Multi-Model LLM — Support for Qwen, OpenAI, DeepSeek, Anthropic, Gemini, and OpenAI-compatible APIs
  • Schema Analysis — AI-powered database analysis with compliance checking and optimization suggestions
  • Performance Benchmarking — Automated sysbench testing with comprehensive analysis reports
  • MCP Integration — Extend capabilities via Model Context Protocol servers
  • Safety First — Read-only by default, DDL/DML requires confirmation (YOLO mode available)

📦 Installation

Requirements

  • Python 3.13+
  • Network access to your RDS instance (currently only MySQL is supported)
  • API access to at least one LLM provider (Qwen / OpenAI / DeepSeek / Anthropic / Gemini / OpenAI-compatible)
  • sysbench (optional, for /benchmark command) — Install from sysbench GitHub

One-Click Installation (Recommended)

The easiest way to install rdsai-cli is using our automated installation script:

# Using curl (recommended)
curl -LsSf https://raw.githubusercontent.com/aliyun/rdsai-cli/main/install.sh | sh

# Or using wget
wget -qO- https://raw.githubusercontent.com/aliyun/rdsai-cli/main/install.sh | sh

Install from PyPI

We recommend using uv as the Python package manager for faster installation and better dependency resolution. For more installation options, see uv installation guide.

# Using uv (recommended - provides isolated environment)
uv tool install --python 3.13 rdsai-cli

# Or using pip (may cause dependency conflicts with other packages)
# Recommended: Use virtual environment: python -m venv .venv && source .venv/bin/activate
pip install rdsai-cli

After installation, the rdsai command will be available globally. Note: Using pip install may cause dependency conflicts with other Python packages. We recommend using uv tool install or installing in a virtual environment.

Install from source (for development)

git clone https://github.com/aliyun/rdsai-cli.git
cd rdsai-cli

# Using uv
uv sync
uv sync --extra dev  # with dev dependencies

# Or using pip
pip install -e ".[dev]"

For development installations, use uv run rdsai or activate the virtual environment first.

🚀 Quick Start

1. Launch the CLI

# Start without connection (interactive mode)
rdsai

# Connect via command line arguments
rdsai --host localhost -u root -p secret -D mydb

# With SSL
rdsai --host db.example.com -u admin -p secret \
  --ssl-mode REQUIRED --ssl-ca /path/to/ca.pem

# Custom port
rdsai --host localhost -P 3307 -u root -p secret

You can start the CLI without any connection parameters and connect later using the interactive /connect command:

Connect to MySQL database:

$ rdsai
> /connect
# Interactive form will prompt for Host, Port, Username, Password, Database

Connect to files or data sources:

# Connect to a CSV file in current directory
> /connect flights.csv

# Connect to a local file
> /connect /path/to/data.csv
> /connect ./data.xlsx

# Connect to a remote file via HTTP/HTTPS
> /connect https://example.com/data.csv

# Connect to multiple files
> /connect file1.csv file2.csv

Supported file formats:

  • CSV files (.csv)
  • Excel files (.xlsx, Excel 2007+ format)

Connection options:

Option Short Description Default
--host -h Database host
--user -u Username
--password -p Password
--port -P Port 3306
--database -D Default database
--yolo -y Auto-approve all actions off
--ssl-mode SSL mode
--ssl-ca CA certificate path
--ssl-cert Client certificate path
--ssl-key Client key path

SSL modes: DISABLED, PREFERRED, REQUIRED, VERIFY_CA, VERIFY_IDENTITY

2. Configure LLM

Use the interactive wizard to configure your LLM provider:

mysql> /setup

The wizard will walk you through:

  1. Select Platform — Qwen, OpenAI, DeepSeek, Anthropic, Gemini, or a generic OpenAI-compatible endpoint
  2. Configure API — Base URL (if needed), API Key, Model Name
  3. Save & Apply — Configuration is persisted and the shell is reloaded automatically

Configuration file:

  • Path: ~/.rdsai-cli/config.json
  • Contains: providers, models, language, default model settings

You can edit this JSON manually for advanced setups.

📖 Basic Usage

SQL Execution

Plain SQL is executed directly against MySQL, with results formatted via Rich:

mysql> SELECT COUNT(*) FROM users;
mysql> SHOW CREATE TABLE orders;
mysql> EXPLAIN SELECT * FROM users WHERE email = 'test@example.com';
mysql> SELECT * FROM users LIMIT 10\G   -- vertical format

Quick Explain with Ctrl+E: After executing any SQL query, press Ctrl+E to get an AI-powered explanation of the result or error. This helps you understand:

  • What the query result means
  • Why a query might be slow or return unexpected results
  • The cause of SQL errors and how to fix them

The explain hint (💡 Ctrl+E: Explain result or 💡 Ctrl+E: Explain error) is automatically shown after each query execution.

Natural Language

Just type what you need; the agent will call tools, run DDL SQL (with confirmation), and explain results:

mysql> analyze index usage on users table
mysql> show me slow queries from the last hour
mysql> check for lock waits
mysql> design an orders table for e-commerce
mysql> why this query is slow: SELECT * FROM users WHERE name LIKE '%john%'
mysql> find tables without primary keys
mysql> show me the replication status

The shell automatically:

  • Detects whether input is SQL or natural language
  • Records query execution history
  • Injects the last query result into the AI context when helpful

Meta Commands

Meta commands start with / and never hit MySQL directly.

Command Alias Description
/connect /conn Connect to MySQL, local files, or remote data sources
/disconnect /disconn Disconnect from current database
/help /h, /? Show help and current status
/exit /quit Exit CLI
/version Show CLI version
/setup Interactive LLM configuration wizard
/reload Reload configuration
/clear /reset Clear AI context (start fresh)
/compact Compact AI context to save tokens
/yolo Toggle YOLO mode (auto-approve actions)
/history /hist Show SQL query execution history
/model /models Manage LLM models (list/use/delete/info)
/explain Analyze SQL execution plan with AI-powered insights
/research Generate comprehensive database schema analysis report
/benchmark Run sysbench performance test with AI-powered analysis
/mcp Manage MCP servers (list/connect/disconnect/enable/disable)

You can still run shell commands via the built-in shell mode when prefixed appropriately (see in-shell help).

📚 Documentation

Complete Tutorial

  • Complete Tutorial — Comprehensive guide from beginner to advanced, including quick start, basic operations, AI features, advanced capabilities, best practices, and FAQ

Core Features

Usage Scenarios

⚡ YOLO Mode

YOLO mode skips confirmation prompts for potentially destructive actions (DDL/DML).

# Enable at startup
rdsai --host localhost -u root -p secret --yolo
# Toggle at runtime
mysql> /yolo on
mysql> /yolo off

Use this only in non-production or when you fully trust the actions being taken.

🔒 Security Notes

  1. Read-Only by Default — The AI runs in a conservative mode; DDL/DML require explicit confirmation unless YOLO is on.
  2. Confirmation Required — Every write operation surfaces the exact SQL for review before execution.
  3. Credential Storage — API keys and model settings are stored in ~/.rdsai-cli/config.json; protect that file with proper OS permissions.
  4. Transaction Safety — The shell warns you about uncommitted transactions when you attempt to exit.

See GitHub Issues for detailed tracking.

🤝 Contributing

We welcome contributions of all kinds! Please see CONTRIBUTING.md for:

  • Development setup
  • Code style guidelines
  • Pull request process
  • Issue reporting

📜 License

This project is licensed under the MIT License - see the LICENSE file for details.


Enjoy building and debugging RDS systems with an AI agent in your terminal 😁

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

rdsai_cli-0.1.8.tar.gz (779.1 kB view details)

Uploaded Source

Built Distribution

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

rdsai_cli-0.1.8-py3-none-any.whl (883.6 kB view details)

Uploaded Python 3

File details

Details for the file rdsai_cli-0.1.8.tar.gz.

File metadata

  • Download URL: rdsai_cli-0.1.8.tar.gz
  • Upload date:
  • Size: 779.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rdsai_cli-0.1.8.tar.gz
Algorithm Hash digest
SHA256 e50b5b0520bdcf9c19358308772b9c0df668417e716fff570dc524e619f3498b
MD5 ea787c7eb5ad5fa13761faa48d3df98c
BLAKE2b-256 97e159415a139a466aa2e95895c5f855112b413ba3ad70fcdaee9c124b71585a

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdsai_cli-0.1.8.tar.gz:

Publisher: python-publish.yml on aliyun/rdsai-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file rdsai_cli-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: rdsai_cli-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 883.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for rdsai_cli-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 e73e1ca62aae5cef7482e63e83ad6a6af93d1b31a56ef1e44131ba51b1dd5d40
MD5 cefcfbb9d169b8bb43366bf4328bceb9
BLAKE2b-256 757cf54312e5204f697fb6590382d6f094ff6e3425f96563949f0b793341661b

See more details on using hashes here.

Provenance

The following attestation bundles were made for rdsai_cli-0.1.8-py3-none-any.whl:

Publisher: python-publish.yml on aliyun/rdsai-cli

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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