Installation
Build the CLI from the workspace root:target/debug/databas_cli.
Usage Modes
The CLI supports two modes of operation:Interactive REPL Mode
Launch the REPL by running the CLI without arguments:Single-Query Mode
Execute a single query by passing it as a command-line argument:Example Sessions
Basic Query Execution
Multiple Statements
You can execute queries with multiple statements:Error Handling
If a query contains syntax errors, the CLI displays an error message:Exiting the CLI
To exit the interactive REPL, type theexit command:
Command Reference
Interactive Commands
| Command | Description |
|---|---|
exit | Exit the interactive REPL session |
| Any SQL query | Parse and display the query structure |
Command-Line Arguments
QUERY(optional): SQL query to execute in single-query mode. If omitted, launches the interactive REPL.
How It Works
The CLI uses thedatabas_sql_parser crate to parse SQL queries. The parsing process:
- Reads input from stdin (REPL mode) or command-line argument (single-query mode)
- Passes the query to the SQL parser
- Iterates through parsed statements
- Displays each successfully parsed statement or shows parsing errors
Tips
- Press Ctrl+C to force-quit the REPL if needed
- The CLI outputs to stdout for successful parses and stderr for errors
- Quote your queries in single-query mode to preserve spacing and special characters
- Each query in the REPL is independent—there’s no persistent state between queries yet
Next Steps
SQL Parser
Learn about the SQL parsing engine
Core Database
Explore the database engine internals