Quickstart
Quickstart
Start here to ingest, query, and chart a real dataset, then open the same project in Studio.
Nothing to install? Try the interactive walkthrough in your browser. Using Trilogy programmatically? See the Python SDK.
1. Install
Install Trilogy with terminal charting and the local Studio server:
pip install --upgrade "pytrilogy[cli,serve]>=0.3.371"
See Installation for other installation options. You'll need internet access to read the hosted data and load Studio.
Create a directory for the demo and run the remaining commands from there:
mkdir baseball-demo
cd baseball-demo
2. Ingest baseball data
trilogy ingest points the CLI at a file - local or remote, CSV, TSV, or Parquet - and writes a model for it.
We'll use team seasons from the Lahman Baseball Database. The hosted CSV includes standings, season totals, parks, and attendance.
trilogy ingest "https://storage.googleapis.com/trilogy_public_models/duckdb/lahman/Teams.csv" duckdb --name teams -o raw
That lands in raw/teams.preql. Trilogy reads the file, verifies the team and year together as the grain, and infers types from the values. The generated model points to the hosted CSV; it doesn't copy the data into a local database.
To discover the concepts available for your own queries:
trilogy explore raw/teams.preql
The data is copyright 1996–2025 by SABR via donation from Sean Lahman, licensed under CC BY-SA 3.0.
3. Query team seasons
Which seasons had the most home runs?
trilogy run --import raw.teams "select year_id, sum(hr) as home_runs order by home_runs desc limit 5;" duckdb
--import raw.teams prepends the model import for you. Trilogy uses the model to find the data, so your query only needs to name the concepts you want.
| year_id | home_runs |
|---|---|
| 2019 | 6776 |
| 2017 | 6105 |
| 2021 | 5944 |
| 2023 | 5868 |
| 2000 | 5693 |
4. Chart the trend
Use the same model to draw a line chart of home runs by season in your terminal:
trilogy run --import raw.teams "chart layer line ( x_axis <- year_id, y_axis <- sum(hr) as home_runs ) order by year_id asc;" duckdb
5. Explore in Studio
Launch Studio against your local project to explore the model and run queries in the browser:
trilogy serve .
This starts the local model server and opens Studio in your browser. Keep the terminal running while you use Studio; press Ctrl+C to stop the server.
Keep going
- Bring your own data - Create a model from your files or database tables.
- Query and build a public model - Fetch the FAA model and build a managed data asset.
- Learn the language - Understand concepts, datasources, and how Trilogy resolves queries.
- CLI reference - Explore the full command set.