Skip to main content

/trino-query

Run a Trino SQL query and return the results.

Usage

/trino-query <SQL query or description>

Provide either a literal SQL query or a description of what you want to run. If you provide a description, the skill will compose the appropriate SQL.

Prerequisites

  1. Copy .env.example to .env and fill in your Trino credentials:

    TRINO_HOST=...
    TRINO_USERNAME=...
    TRINO_PASSWORD=...
    TRINO_PORT=...
  2. Install dependencies: poetry install (creates the .venv/ with pandas, tqds, and python-dotenv).

What It Does

  1. Loads environment — reads Trino credentials from .env and verifies all four variables are set.
  2. Verifies the Poetry venv — checks that .venv/ exists (prompts you to run poetry install if not).
  3. Runs the query — executes the SQL via tqds.sql.db.TrinoClient and loads results into a pandas DataFrame. Displays up to 50 rows; if more, shows the first 50 with a count of omitted rows.
  4. Reports errors — if the query fails, shows the error and stops.

Common Tables

TablePartition
tq_production.clear_rates_{yyyy_mm}.clear_ratespayer_id
tq_production.public_{yyyy_mm}.core_ratespayer_id
tq_production.hospital_data.hospital_ratesprovider_id
tq_production.spines.*varies
tq_dev.internal_dev_csong_cld_{version}.*varies