A command-line interface for MindsDB written in Go. This tool allows you to interact with MindsDB instances directly from your terminal, enabling you to connect, manage models, and run predictions with ease.
- Easy Connection: Connect to MindsDB instances using PostgreSQL or MySQL protocols
- Model Management: Create and list machine learning models
- Interactive SQL Mode: REPL-like interface with persistent connections, multi-line queries, and special commands
- Smart Query Execution: Run SQL queries with adaptive table formatting, multiple output formats (table/JSON/CSV), and intelligent text wrapping
- Beautiful CLI: Clean interface with helpful banners and status messages
- Cross-platform: Works on macOS, Linux, and Windows
- β Embedded MindsDB: No separate installation required! Run MindsDB directly from the CLI using Docker
- Go 1.23 or higher
- Docker (for embedded MindsDB support)
- Optional: Access to an external MindsDB instance (local or cloud)
# Clone the repository
git clone <repository-url>
cd mindsdb-cli
# Build the application
go build -o mindsdb-cli
# Make it executable (on Unix-like systems)
chmod +x mindsdb-cli
# Optionally, move to PATH
sudo mv mindsdb-cli /usr/local/bin/Run the CLI without any arguments to see the welcome banner:
mindsdb-cliThis will display:
- MindsDB ASCII logo
- Version information
- Available commands
- Getting started instructions
Use MindsDB without any separate installation - everything runs in Docker:
# Start embedded MindsDB (automatically downloads and starts MindsDB)
mindsdb-cli start --user admin --pass admin
# Connect and start interactive SQL mode
mindsdb-cli query
# Or connect once to test
mindsdb-cli connect --embedded --user admin --pass admin
# Check status
mindsdb-cli status
# Stop when done
mindsdb-cli stopIf you have MindsDB already running (locally or remotely):
# Connect to localhost (default MindsDB installation)
mindsdb-cli connect --host localhost:47335 --user mindsdb --pass ""
# Connect to MindsDB Cloud
mindsdb-cli connect --host cloud.mindsdb.com --user your_email --pass your_password
# Connect to a custom MindsDB instance
mindsdb-cli connect --host your-host:port --user username --pass passwordIf you prefer to install MindsDB separately:
# Using pip
pip install mindsdb
# Start MindsDB
python -m mindsdb
# Then connect from another terminal
mindsdb-cli connect --host localhost:47335 --user mindsdb --pass ""Start MindsDB in a Docker container:
mindsdb-cli start --user admin --pass adminFlags:
--user: Username for MindsDB (optional, only needed if auth is enabled)--pass: Password for MindsDB (optional, only needed if auth is enabled)
What it does:
- Checks if Docker is available
- Pulls the MindsDB Docker image if needed
- Starts the MindsDB container
- Waits for MindsDB to be ready
Stop the MindsDB container:
mindsdb-cli stop # Stop the container
mindsdb-cli stop --remove # Stop and remove the containerFlags:
--remove: Remove the container after stopping
Check the status of your embedded MindsDB instance:
mindsdb-cli statusShows:
- Docker availability
- MindsDB container status
- Connection information if running
- Available commands
Connect to a MindsDB instance (embedded or external):
# Connect to embedded instance
mindsdb-cli connect --embedded --user admin --pass admin
# Connect to external instance
mindsdb-cli connect --host localhost:47335 --user mindsdb --pass ""Flags:
--host: MindsDB host and port (e.g., "localhost:47335")--user: Username for authentication--pass: Password for authentication--embedded: Connect to embedded MindsDB instance
View all available models in your MindsDB instance:
mindsdb-cli list-modelsTrain a new machine learning model:
mindsdb-cli create-model --name my_model --from source_table --predict target_columnFlags:
--name: Name for the new model--from: Source table containing training data--predict: Target column to predict
Example:
mindsdb-cli create-model --name house_price_predictor --from real_estate_data --predict priceRun SQL queries and predictions with multiple output formats:
# Interactive mode (like Python or Node.js REPL)
mindsdb-cli query # Starts interactive SQL prompt
# Basic queries
mindsdb-cli query --sql "SELECT * FROM mindsdb.models"
mindsdb-cli query "SHOW DATABASES"
# Make predictions
mindsdb-cli query --sql "SELECT price FROM house_price_predictor WHERE bedrooms=3 AND bathrooms=2"
# Use with embedded instance
mindsdb-cli query --embedded "SELECT name FROM models"
# Use with external instance
mindsdb-cli query --host localhost:47335 --user admin --pass admin "SHOW TABLES"
# Different output formats for large datasets
mindsdb-cli query --format json "SELECT * FROM training_data"
mindsdb-cli query --format csv "SELECT * FROM models"
# Control table width for better readability
mindsdb-cli query --max-width 30 "SELECT * FROM large_content_table"
mindsdb-cli query --compact "SELECT * FROM very_large_table"
# Handle wide tables with many columns
mindsdb-cli query --vertical "SELECT * FROM models" # Force vertical layout
mindsdb-cli query --limit 5 "SELECT * FROM big_dataset" # Limit rows displayedInteractive Mode Features:
- REPL-like interface: Just like Python or Node.js interactive mode
- Multi-line queries: Use semicolon (
;) to execute, or press Enter on empty line - Persistent connection: Connection stays active throughout your session
- Special commands:
.help,.exit,.format <table|json|csv>,.compact,.vertical,.limit <num>,.clear - Smart prompts:
mindsdb>for new queries,...for continued lines - Auto-detection: Wide tables automatically switch to vertical layout
Interactive Example:
$ mindsdb-cli query
π§ MindsDB Interactive SQL Mode
================================
π‘ Type SQL queries and press Enter to execute
π‘ Use semicolon (;) for multi-line queries
π‘ Commands: .help, .exit, .format, .compact, .vertical, .limit
π Connecting to embedded MindsDB (default)...
β
Connected! Ready for queries.
mindsdb> SHOW DATABASES;
[results displayed]
mindsdb> SELECT * FROM models;
π‘ Wide table detected (19 columns) - using vertical layout for better readability
[vertical layout results displayed]
mindsdb> .limit 3
β
Row limit set to: 3
mindsdb> SELECT name, status
... FROM models
... WHERE accuracy > 0.8;
π‘ Showing first 3 rows (use --limit 0 to show all)
[results displayed]
mindsdb> .vertical
β
Vertical layout enabled
mindsdb> .format json
β
Output format changed to: json
mindsdb> SELECT * FROM models;
[JSON results displayed]
mindsdb> .exit
π Goodbye!Flags:
--sql: SQL query to execute--embedded: Use embedded MindsDB instance--host,--user,--pass: External MindsDB connection details--format: Output format -table(default),json, orcsv--max-width: Maximum column width for table display (default: 30)--compact: Use compact mode for very readable tables with narrow columns--vertical: Force vertical layout for wide tables (great for many columns)--limit: Limit the number of rows displayed (0 for no limit)
The CLI automatically adapts table display based on your terminal size and content structure:
Adaptive Features:
- Terminal Width Detection: Tables automatically fit your terminal width
- Wide Table Auto-Detection: Tables with 8+ columns automatically use vertical layout
- Vertical Layout: Each row displayed as key-value pairs for maximum readability
- Column Width Limits: Long content is intelligently truncated with ellipsis
- Smart Text Wrapping: Content wraps at word boundaries when possible
- Multiple Output Formats: Switch to JSON or CSV for large datasets
- Customizable Width: Control maximum column width with
--max-width - Compact Mode: Ultra-readable tables with
--compactfor dense data - Row Limiting: Control how many rows to display with
--limit
Examples:
# Compact display for large content
mindsdb-cli query --max-width 25 "SELECT * FROM training_data"
# Ultra-compact mode for very dense data
mindsdb-cli query --compact "SELECT * FROM conversation_logs"
# Force vertical layout for wide tables (perfect for model info)
mindsdb-cli query --vertical "SELECT * FROM models"
# Limit rows for quick previews
mindsdb-cli query --limit 3 "SELECT * FROM large_dataset"
# JSON format for programmatic use
mindsdb-cli query --format json "SELECT * FROM models" | jq .
# CSV format for data analysis
mindsdb-cli query --format csv "SELECT name, accuracy FROM models" > models.csvWide Table Example (Vertical Layout):
$ mindsdb-cli query "SELECT * FROM models"
π Results:
π‘ Wide table detected (19 columns) - using vertical layout for better readability
π Row 1:
ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
NAME : my_model
ENGINE : lightgbm
PROJECT : mindsdb
ACTIVE : true
VERSION : 1
STATUS : complete
ACCURACY : 0.95
PREDICT : target_column
UPDATE_STATUS : up_to_date
MINDSDB_VERSION : 23.10.3.0
ERROR : NULL
...
β
Query completed successfully (1 row)Get help for any command:
# General help
mindsdb-cli --help
# Command-specific help
mindsdb-cli connect --help
mindsdb-cli start --help
mindsdb-cli create-model --helpmindsdb-cli/
βββ main.go # Application entry point
βββ go.mod # Go module dependencies
βββ cmd/ # CLI commands (Cobra-based)
β βββ root.go # Root command and CLI setup
β βββ connect.go # Connection command
β βββ start.go # Start embedded MindsDB
β βββ stop.go # Stop embedded MindsDB
β βββ status.go # Check MindsDB status
β βββ create_model.go # Model creation command
β βββ list_models.go # Model listing command
β βββ query.go # Query execution command
βββ internal/ # Internal packages
β βββ mindsdb/
β βββ client.go # MindsDB client implementation
βββ LICENSE # Project license
βββ README.md # This file
-
Main Entry Point (
main.go)- Simple entry point that delegates to the Cobra command system
-
CLI Commands (
cmd/)- Root Command (
root.go): Main CLI setup, banner display, and command registration - Start (
start.go): Starts embedded MindsDB in Docker - Stop (
stop.go): Stops embedded MindsDB container - Status (
status.go): Checks Docker and container status - Connect (
connect.go): Handles connection to MindsDB instances (embedded/external) - Create Model (
create_model.go): Manages model creation workflow - List Models (
list_models.go): Lists available models - Query (
query.go): Executes SQL queries and predictions
- Root Command (
-
MindsDB Client (
internal/mindsdb/client.go)- PostgreSQL Client: For communicating with external MindsDB instances
- MySQL Client: For communicating with embedded MindsDB instances
- Docker Management: Complete container lifecycle management (start, stop, status)
- Connection Management: Automatic protocol detection and connection handling
- Health Checking: Ensures MindsDB is ready before connecting
- Cobra: Modern CLI framework for Go
- pgx: PostgreSQL driver for Go (external MindsDB connections)
- go-sql-driver/mysql: MySQL driver for Go (embedded MindsDB connections)
- fatih/color: Colored terminal output
- Command Pattern: Each CLI command is implemented as a separate Cobra command
- Client Pattern: MindsDB client abstracts connection and communication logic
- Flag-based Configuration: Commands use flags for parameter input
- Protocol Abstraction: Supports both PostgreSQL and MySQL protocols transparently
The CLI now provides a completely self-contained MindsDB experience, eliminating the need for users to install MindsDB separately.
- β Docker integration for embedded MindsDB
- β Container lifecycle management (start, stop, status)
- β Automatic MindsDB image download and setup
- β Health checking and connection management
- β Port management and networking
- β Data persistence across container restarts
mindsdb-cli
βββ Docker Management Layer β
β βββ Container lifecycle (start/stop/status)
β βββ Image management (pull/update)
β βββ Port management and networking
βββ Connection Abstraction β
β βββ Embedded mode (localhost Docker + MySQL)
β βββ External mode (remote MindsDB + PostgreSQL)
βββ CLI Interface β
βββ Unified commands work with both modes
βββ Automatic mode detection
- β Zero Installation: No need to install MindsDB separately
- β Version Consistency: CLI and MindsDB versions are matched
- β Isolated Environment: No conflicts with system Python/packages
- β Easy Updates: Single binary update includes everything
- β Portability: Works anywhere Docker is available
- β Quick Setup: Get started in minutes
- Go 1.23 or higher
- Git
- Docker (for embedded features)
- Optional: A running MindsDB instance for testing external connections
# Clone the repository
git clone <repository-url>
cd mindsdb-cli
# Install dependencies
go mod tidy
# Run the application
go run main.go
# Run tests (when available)
go test ./...
# Build for development
go build -o mindsdb-cli-dev- Commands: Add new commands in the
cmd/directory following the existing pattern - Client Logic: Extend the MindsDB client in
internal/mindsdb/client.go - Utilities: Add shared utilities in appropriate internal packages
- Create a new file in
cmd/(e.g.,cmd/new_command.go) - Define the command using Cobra conventions
- Register the command in
cmd/root.goinit function - Add any necessary flags and validation
Example:
var newCmd = &cobra.Command{
Use: "new-command",
Short: "Description of the new command",
Run: func(cmd *cobra.Command, args []string) {
// Command implementation
},
}
func init() {
// Add flags if needed
newCmd.Flags().StringVar(&flagVar, "flag", "default", "Flag description")
}- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Add tests if applicable
- Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the terms specified in the LICENSE file.
- β Basic CLI structure with Cobra
- β PostgreSQL connection to external MindsDB instances
- β MySQL connection to embedded MindsDB instances
- β Core commands: connect, list-models, create-model, query
- β Interactive SQL mode with REPL-like interface
- β Smart table formatting with multiple output formats
- β Docker integration for embedded MindsDB
- β Container lifecycle management (start/stop/status)
- β Automatic MindsDB image download
- β Health checking and auto-connection
- β Cross-platform builds
- π Enhanced model management features
- π Configuration file support
- π Interactive mode with auto-completion
- π Export/import functionality for models
- π Comprehensive test suite
- π Binary embedding (explore MindsDB as Go library)
- π Plugin system for custom extensions
- π Advanced monitoring and logging
- π Multi-container orchestration
Version: 0.2.0
Go Version: 1.23+