{"id":27318,"library":"pytrilogy","title":"pytrilogy","description":"A declarative, typed query language that compiles to SQL. Current version 0.3.246. Release cadence is frequent, pre-1.0 breaking changes may occur.","status":"active","version":"0.3.246","language":"python","source_language":"en","source_url":"https://github.com/trilogy-libraries/pytrilogy","tags":["sql","query-language","compiler","declarative","typed"],"install":[{"cmd":"pip install pytrilogy","lang":"bash","label":"PyPI"}],"dependencies":[],"imports":[{"wrong":"from pytrilogy import compile","symbol":"compile","correct":"from trilogy import compile"},{"symbol":"CONFIG","correct":"from trilogy import CONFIG"},{"symbol":"Dialects","correct":"from trilogy import Dialects"}],"quickstart":{"code":"from pytrilogy import compile\n\nquery = '''\nimport std\n\n# Declare a variable\nlet x = 5\n\n# Return the variable as a column named \"val\"\nsource = from x in std.from_list([x]) select { val: x }\n'''\n\nresult = compile(query, dialect='postgres')\nprint(result.sql)","lang":"python","description":"Compile a simple Trilogy query to SQL. The compile function returns an object with .sql and .params attributes."},"warnings":[{"fix":"Pin version in requirements, e.g., pytrilogy==0.3.246.","message":"The library is pre-1.0; breaking changes occur frequently. Pin your version or expect sudden API changes.","severity":"breaking","affected_versions":"<1.0"},{"fix":"Use 'from pytrilogy import compile'.","message":"The 'compile' function must be imported directly from the package. Importing pytrilogy and calling pytrilogy.compile may fail.","severity":"gotcha","affected_versions":"all"},{"fix":"Check the supported dialects in the documentation. Use a known dialect like 'postgres' or 'bigquery'.","message":"The library expects a specific dialect string (e.g., 'postgres', 'bigquery', 'sqlite'). Using an unsupported dialect may cause cryptic errors.","severity":"gotcha","affected_versions":"all"},{"fix":"Update to 'from pytrilogy import compile'.","message":"Older versions used 'from pytrilogy import pytrilogy_compile' or similar; always use the top-level 'compile'.","severity":"deprecated","affected_versions":"<0.3.0"}],"env_vars":null,"search_vec":"'-1.0':19 '0.3.246':13 'break':20 'cadenc':15 'chang':21 'compil':8,28 'current':11 'declar':3,29 'frequent':17 'languag':6,27 'may':22 'occur':23 'pre':18 'pytrilog':1 'queri':5,26 'query-languag':25 'releas':14 'sql':10,24 'type':4,30 'version':12","created_at":"2026-05-01T17:45:39.076562+00:00","updated_at":"2026-05-01T17:45:39.076562+00:00","problems":{"verify_error":"Traceback (most recent call last):\n  File \"<string>\", line 1, in <module>\nImportError: cannot import name 'compile' from 'trilogy' (/tmp/tmpf6ujy076/venv/lib/python3.12/site-packages/trilogy/__init__.py)"},"ecosystem":"pypi","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":"","cli_version":null,"type":"library","homepage":"https://pytrilogy.com","github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/pytrilogy/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["data","database","serialization"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"import_fail","verified_at":"2026-07-03","last_verified":"2026-07-03","next_check":"2026-07-10","install_tag":null}}