Skip to content

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

SubcommandDescription
schemaShow schema for a table or view
searchFull-text search across models
tablesList all tables and views in the state database
viewsList views only

Options

OptionShortDefaultDescription
--format-ftableOutput format: table, json, csv, md
--input-iRead SQL from file

Global Options

OptionShortDefaultDescription
--configconfig file (default: ./leapsql.yaml)
--databasePath to DuckDB database (empty for in-memory)
--envEnvironment name
--macros-dirPath to macros directory
--models-dirPath to models directory
--output-oOutput format (auto|text|markdown|json)
--project-dir-CProject root directory (auto-detected from models-dir or config file location)
--seeds-dirPath to seeds directory
--statePath to state database
--target-tTarget environment to use (e.g., dev, staging, prod)
--verbose-vfalseVerbose 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

Released under the MIT License.