An intelligent database management tool that brings AI-powered assistance to your database operations.
- 🧠 AI-Powered: Convert natural language queries into optimized SQL
- 🛡️ Safety First: Built-in protection against dangerous operations
- 🔌 Multi-Database: Support for PostgreSQL, MySQL, and SQLite
- 💻 Cross-Platform: Works on Linux, macOS, and Windows
# Linux / macOS - Install to /usr/local/bin (requires sudo)
curl -fsSL https://raw.githubusercontent.com/murongg/dbsage/main/install.sh | sudo bash
# Windows: Download install.bat and run as administrator# Linux / macOS - Install to current directory (no sudo required)
curl -fsSL https://raw.githubusercontent.com/murongg/dbsage/main/install.sh | bash -s -- --local
# Run with ./dbsage in the installation directory# Force reinstallation
curl -fsSL https://raw.githubusercontent.com/murongg/dbsage/main/install.sh | sudo bash -s -- --force
# Install to custom directory
curl -fsSL https://raw.githubusercontent.com/murongg/dbsage/main/install.sh | sudo bash -s -- --dir /opt/bin
# Show help
curl -fsSL https://raw.githubusercontent.com/murongg/dbsage/main/install.sh | bash -s -- --helpgit clone https://github.com/murongg/dbsage.git
cd dbsage/go
make setup
make run-
Configure API Key
# Set environment variable (choose one method): # Method 1: Temporary (current session only) export OPENAI_API_KEY=your_api_key_here # Method 2: Permanent (add to shell config) echo 'export OPENAI_API_KEY=your_api_key_here' >> ~/.zshrc # or ~/.bashrc source ~/.zshrc # or ~/.bashrc
-
Launch DBSage
dbsage
-
Add Database
/add test connection # Follow prompts to enter database details
-
Start Querying
"Show me all users created this month" "Find slow queries in the database" "Suggest indexes for the orders table"
# Command Line Options
dbsage --version # Show version information
dbsage -v # Show version information (short)
dbsage --help # Show usage help
# Connection Management
/add test connection # Add database connection
/switch production # Switch database
/list # Show all connections
/remove test # Remove connection
# General Commands
/help # Show available commands
/clear # Clear screen
/exit or /quit # Exit application
# Quick Access
@ # Show connections
@production # Quick switch to connection
@<query> # Execute database query directlySet these in your shell environment:
# Required
export OPENAI_API_KEY=your_openai_api_key_here
# Optional
export OPENAI_BASE_URL=https://api.openai.com/v1 # Default OpenAI endpointAdd to your shell configuration file (~/.zshrc, ~/.bashrc, or ~/.profile):
export OPENAI_API_KEY=your_openai_api_key_here
export OPENAI_BASE_URL=https://api.openai.com/v1 # OptionalThen reload your shell configuration:
source ~/.zshrc # or ~/.bashrc, ~/.profileYou: "Query the first 10 users"
DBSage: SELECT * FROM users LIMIT 10;
You: "This query is slow: SELECT * FROM orders WHERE created_at > '2024-01-01'"
DBSage: 🚀 Optimization suggestions:
1. Add index: CREATE INDEX idx_orders_created_at ON orders (created_at);
2. Avoid SELECT *, specify required columns
3. Consider date partitioning for large tables
You: "DELETE FROM users WHERE active = false"
DBSage: ⚠️ DANGEROUS OPERATION DETECTED ⚠️
This will DELETE 1,247 records. Please confirm.
- Documentation: GitHub Repository
- Issues: GitHub Issues
- Releases: GitHub Releases