query
Query the LeapSQL state database directly.
Execute SQL queries against the state database to inspect runs, models, dependencies, and other pipeline metadata. Supports multiple output formats for scripting and integration.
When invoked without arguments, enters interactive REPL mode.
Usage
bash
leapsql query <subcommand> [options]Subcommands
| Subcommand | Description |
|---|---|
schema | Show schema for a table or view |
search | Full-text search across models |
tables | List all tables and views in the state database |
views | List views only |
Options
| Option | Short | Default | Description |
|---|---|---|---|
--format | -f | table | Output format: table, json, csv, md |
--input | -i | Read SQL from file |
Global Options
| Option | Short | Default | Description |
|---|---|---|---|
--config | config file (default: ./leapsql.yaml) | ||
--database | Path to DuckDB database (empty for in-memory) | ||
--env | Environment name | ||
--macros-dir | Path to macros directory | ||
--models-dir | Path to models directory | ||
--output | -o | Output format (auto|text|markdown|json) | |
--project-dir | -C | Project root directory (auto-detected from models-dir or config file location) | |
--seeds-dir | Path to seeds directory | ||
--state | Path to state database | ||
--target | -t | Target environment to use (e.g., dev, staging, prod) | |
--verbose | -v | false | Verbose output |
Examples
bash
# Execute SQL directly
leapsql query "SELECT * FROM v_runs"
# List available tables
leapsql query tables
# Show schema for a table
leapsql query schema models
# Full-text search
leapsql query search "revenue"
# Output as JSON
leapsql query "SELECT * FROM v_models" --format json
# Interactive mode
leapsql query