Datasource examples
Datasource examples
These recipes run locally with DuckDB. Each includes its input files, a complete Trilogy model, and an expected result. Download the linked files into one folder and run commands from that folder.
| Recipe | What it shows |
|---|---|
| Local files | Map CSV columns to concepts and aggregate them |
| SQL and Python scripts | Read a SQL query file or execute a Python Arrow producer |
| Multiple files | Combine partitions with an explicit file list or glob |
| Read and write addresses | Read a published address and persist to a separate output |
Local setup
Install uv and the Trilogy CLI. These recipes were tested with pytrilogy 0.3.404 and DuckDB 1.5.6. For that same environment:
uv tool install --with "duckdb==1.5.6" "pytrilogy==0.3.404"
The DuckDB pin also avoids the DuckDB 2.0 extension compatibility issue with this Trilogy release. Python script datasources need network access on their first run to install the script dependencies and DuckDB extensions.
Local paths resolve relative to the model file. These examples use local files, so run them with the CLI rather than the shared web query runner. See the datasource syntax reference for binding options and Run for CLI options.