dql query
Synopsis
dql query [options] [<query>]
dql q [options] [<query>]
Description
Compile a DelightQL expression and either display intermediate output or execute it against a database. The query can be given as a positional argument, read from a file, or piped via stdin.
When no query is provided and stdin is a terminal, the REPL starts. See dql-repl(1).
Examples
# Inline query
dql query --db data.db "users(*)"
# From a file
dql query --db data.db --file query.dql
# From stdin
echo 'users(*)' | dql query --db data.db
# File redirection
<query.dql dql query --db data.db
# Show generated SQL only
dql query --db data.db --to sql "users(*)"
# Output as JSON
dql query --db data.db -f json "users(*)"
# Multiple queries in sequence
dql query --db data.db --sequential --file setup_and_query.dql
# Load DDL definitions before querying
dql query --db data.db --consult defs.dql "my_view(*)"
Options
Input
<query>
Query string. If omitted, reads from --file or stdin.
--file path
Read query from a file.
--sequential
Process the file as multiple queries, executing each in order.
--consult path
Load DDL definitions from a .dql file before running the query. May be repeated.
--attach path
Attach an external SQLite database, accessible via schema-qualified names.
Output
--to stage
Control how far the compilation pipeline runs.
| Value | Description |
|---|---|
results |
Execute and display results (default) |
sql |
Generated SQL |
cst |
Concrete Syntax Tree (tree-sitter) |
ast-unresolved |
AST before name resolution |
ast-resolved |
AST after name/column resolution |
ast-refined |
AST after refinement |
ast-sql |
SQL AST (before text generation) |
hash |
Data hash (column-name independent) |
bhash |
Byte-level data hash (type-preserving) |
totalhash |
Hash including column names |
fingerprint |
Full fingerprint JSON |
-f, --format fmt
Output format when --to results. One of: table (default), json, csv, tsv, list.
-n, --no-headers
Suppress column headers in output.
-q, --quiet
Suppress non-essential output.
--no-sanitize
Disable output sanitization. Allows raw terminal control sequences in results.
Compilation
--strict
Enable strict validation mode.
--inline-ctes
Inline CTEs as subqueries in generated SQL.
--soptimize level
SQL optimization level. 0–3, default 0.
Side effects
--sink name=path
Bind a named emit stream to a file sink (JSONL). May be repeated. Unbound streams fall back to RS-prefixed records on stderr.
--assert query
Assertion query to run after the main query. May be repeated.
--if-errors query
Format errors with a DelightQL query.
Tuning
--danger uri=state
Override default danger gate states. State is ON, OFF, ALLOW, or 1–9. May be repeated.
--option uri=state
Override default option states. Same state values as --danger. May be repeated.
Database
--db database
Database file or connection URI. See dql-databases(1).
--make-new-db-if-missing
Create the database file if it does not exist.
Display
-i, --interactive
Allow dot commands in non-REPL mode.
--verbose
Verbose mode.
--debug flags
Comma-separated debug flags.
--highlights path
Path to a highlights.scm file for syntax coloring.
--theme path
Path to a TextMate theme file.
See Also
dql(1), dql-repl(1), dql-databases(1), dql-pipeline(1)