

Trilogy is an experiment in better SQL; composable, reusable, and delightful. Write once. Run on any table.
Familiar
Trilogy looks like SQL, just simpler.
Accurate
Eliminate common pitfalls around grouping and joins.
Testable
Separate business logic from data. Types enforced at compile time.
Efficient
Minimize temp and staging tables. Run just what you need.
Extendable
Open source. Rich python API.
Composable
Share, reuse, and compose models.
Future-Proof
Simpler than SQL for humans and AI.
Install
pip install pytrilogy
Hello, World
#-- define your model
const greeting <- 'hello';
key object string;
#-- bind it to data
datasource objects (
object:object
)
grain (object)
query '''
select unnest(['world', 'friend', 'visitor']) as object
''';
#-- and run your SQL
WHERE object like '%world%' or object = 'friend'
SELECT
greeting || ' ' || object || '!' as salutation,
rank salutation by len(salutation) asc as brevity_rank
;