A modern command line interface for Apache Doris
- Interactive SQL command line interface
- Query progress tracking
- Query profile collection
- Syntax highlighting
- Command history
- Auto-suggestions
- Benchmark mode
- Formatted tabular output
- CSV export
Use the provided build-install script to automatically check for dependencies, build and install doris-cmd:
# Clone the repository
git clone https://github.com/morningman/doris-cmd.git
cd doris-cmd
# Run the build-install script
./build-install.shFor source installation only (standalone binary has no requirements):
- Python 3.6 or higher
- Required packages (automatically installed):
- mysql-connector-python
- pymysql
- requests
- tabulate
- prompt-toolkit
- click
- pygments
- rich
# Connect to local Doris instance
doris-cmd
# Connect to specific host and port
doris-cmd --host <hostname> --port <port> --user <username> --password <password>
# Specify a database
doris-cmd --database <database>
# Use a configuration file
doris-cmd --config /path/to/config.iniYou can specify connection settings in a configuration file:
[doris]
host = your_doris_host
port = 9030
user = root
password = your_password
database = your_databaseCommand line arguments take precedence over configuration file values.
# Execute a single query
doris-cmd -e "SELECT * FROM my_table LIMIT 10"
# Execute queries from a file
doris-cmd -f my_queries.sql
# Use a configuration file and execute a query
doris-cmd --config /path/to/config.ini -e "SHOW DATABASES"Profile mode collects detailed query execution information for debugging and performance analysis.
# Execute a query and collect the profile information
doris-cmd --profile -e "SELECT * FROM my_table"
# Execute queries from a file with profile collection
doris-cmd --profile -f my_queries.sql
# Use profile mode in interactive shell
doris-cmd --profileProfile information is saved to /tmp/.doris_profile/doris_profile_<query_id>.txt and includes detailed execution data about the query.
# Run benchmark on SQL queries from a file
doris-cmd --benchmark path/to/queries.sql --times 3# Output results to a CSV file
doris-cmd -e "SELECT * FROM my_table" --output results.csvInside the interactive shell:
- Use semicolon (
;) followed by Enter to execute a query - Type
helpor\hto display help - Type
exit,quit, or\qto exit - Use
\dorshow databasesto show databases - Use
\torshow tablesto show tables - Press Ctrl+D to cancel any running query and exit
doris-cmd includes a packaging script to build standalone executables that don't require Python or any other dependencies:
# Run the packaging script to build a standalone binary for your platform
./package.shThe resulting binaries will be placed in the dist/ directory, named according to your platform:
doris-cmd-linux-0.2.0- When built on Linuxdoris-cmd-macos-0.2.0- When built on macOS
- Python 3.6+ and PyInstaller
To quickly test the installation:
# Show help
doris-cmd --help
# Test connection to a Doris instance
doris-cmd --host localhost --port 9030 --user root --execute "SHOW DATABASES"
# Test profile collection
doris-cmd --host localhost --port 9030 --user root --profile -e "SELECT * FROM my_table"If you encounter any issues:
-
Make sure all dependencies are installed (if using source installation):
pip install -r requirements.txt
-
Check if Python 3.6+ is available (if using source installation):
python3 --version
-
If you experience connection issues, check if your Doris server is running and accessible.
Apache License 2.0