CLI Quickstart
CLI Quickstart
Installation
pip install pytrilogy[cli]
The CLI lets you run Trilogy queries directly by passing in a query + engine to the run command.
trilogy run "SELECT 1 + 1->test;" duckdb
We'll see in a ltitle bit how to simplify this.
Creating Useful Projects
trilogy init <folder>
cd folder
trilogy run hello_world.preql
This will bootstrap a project for you to work in. In the root of the repo is a trilogy.toml file.
This file can be edited to provide defaults to the CLI behavior - environment variables, connection configuration, options, etc.
Tips
The CLI will always utilize the first config file found descending from the root of the target file/directory for the operation.
Example Configuration
A basic file saying that 'duckdb' should be the default backend used.
[engine]
dialect = "duckdb"
This information can also be passed into the CLI as <connection_info>.
Import Existing Tables
Any data work starts with the data.
trilogy ingest "https://storage.googleapis.com/trilogy_public_models/duckdb/trees/sf_tree_info.parquet,https://storage.googleapis.com/trilogy_public_models/duckdb/trees/boston_tree_info.parquet" -o ./raw
This will import a table definition into the raw sub folder. These will be default assumed to be 'roots', or tables that are not created/managed by trilogy.
Execute a new script
Write a new script, such as select 1 as hello_world_two;. Save it in your directory and run it.
trilogy run <file/directory>
Interactively Query Your Model
trilogy serve <directory>
Will block and serve the directory as a web service, and auto-load the public studio UI app to provide a UX for querying it.
Tips
This requires internet access to load! You can configure the target studio URL in the trilogy.toml file if you run a local instance you want to use instead.