Run
Run
The run command executes a Trilogy script, an inline query, or every script in a directory against a specified database.
Usage
trilogy run <input> [dialect] [options] [conn_args...]
Arguments
| Argument | Description |
|---|---|
input | Path to a Trilogy script or directory, or an inline query string. |
dialect | Database dialect. Optional - falls back to engine.dialect in trilogy.toml. |
conn_args | Connection arguments, as key value pairs or key=value tokens. |
Options
| Option | Description |
|---|---|
--param key=value | Environment parameters. Repeatable. |
-p, --parallelism INTEGER | Maximum parallel workers for directory execution. |
--config PATH | Path to a trilogy.toml configuration file. |
-e, --env TEXT | Set env vars as KEY=VALUE, or pass an env file path. |
--import TEXT | Prepend an import to an inline query. Repeatable. |
--displayed-rows INTEGER | Cap on result rows displayed per statement. Default 25. |
--all-rows | Show every result row, overriding --displayed-rows. |
Supported Dialects
| Dialect | Aliases | Connection arguments |
|---|---|---|
duck_db | duckdb | path |
sqlite | sqlite3 | path |
postgres | host, port, username, password, database | |
bigquery | project | |
snowflake | account, username, password, database, schema | |
sql_server | host, port, username, password, database | |
presto | host, port, username, password, catalog, schema | |
trino | host, port, username, password, catalog, schema | |
clickhouse | chdb | host, port, username, password, database, mode |
Connection arguments are passed as key=value (or key value) pairs. A bare connection string is not accepted.
Full Examples
# Run single script with DuckDB
trilogy run query.preql duckdb
# Run against a DuckDB file on disk
trilogy run query.preql duckdb path=shop.duckdb
# Run against Postgres
trilogy run etl.preql postgres host=localhost port=5432 username=app password=secret database=shop
# Run directory with parallelism
trilogy run jobs/ duckdb -p 4
# Run with parameters
trilogy run report.preql duckdb --param date=2024-01-01 --param region=US
# Run with config file
trilogy run script.preql --config custom_config.toml
Inline Queries
An inline query runs directly, using the current working directory as its model path. Use --import to reach an existing model:
trilogy run --import raw.orders "select customers.name, sum(amount) as revenue;" duckdb
--import takes the same dotted form as an in-file import, so raw.orders:o becomes import raw.orders as o;. Slash and .preql path forms still work and are converted, but the dotted form is preferred so CLI and file syntax match.
Note that inline queries use Trilogy syntax, not SQL - there is no FROM clause, because the model already knows where concepts live.
Output Control
By default only the first 25 rows of each statement are displayed; the query still runs in full. When a result exceeds the cap the table is middle-truncated, so you see both the head and the tail, and the footer reports displayed-vs-total rows.
# Show everything, useful for piping
trilogy run report.preql duckdb --all-rows
# Raise the cap
trilogy run report.preql duckdb --displayed-rows 200
Notes
- When running a directory, scripts are executed in dependency order
- The
--parallelismoption controls how many scripts run concurrently - Parameters support automatic type conversion (true/false to boolean, numeric strings to numbers)