Skip to content

Trino

Installation

pip install "toolfront[trino]"

Connection URL

Connect to Trino by passing a connection URL to the Database constructor:

1
2
3
4
5
from toolfront import Database

db = Database(url="trino://{user}:{password}@{host}:{port}/{catalog}/{schema}")

revenue = db.ask("What's our total revenue this month?")

Connection Parameters

Alternatively, connect using the Database.from_trino() method with parameters:

from toolfront import Database

db = Database.from_trino(
    user="user",
    password="pass",
    host="localhost",
    port=8080,
    database="sales",
    schema="public"
)

revenue = db.ask("What's our total revenue this month?")
PARAMETER DESCRIPTION
user

Username to connect with. Default is 'user'.

TYPE: str DEFAULT: 'user'

password

Password to connect with. Mutually exclusive with auth.

TYPE: str DEFAULT: None

host

Hostname of the Trino server. Default is 'localhost'.

TYPE: str DEFAULT: 'localhost'

port

Port of the Trino server. Default is 8080.

TYPE: int DEFAULT: 8080

database

Catalog to use on the Trino server.

TYPE: str DEFAULT: None

schema

Schema to use on the Trino server.

TYPE: str DEFAULT: None

source

Application name passed to Trino.

TYPE: str DEFAULT: None

timezone

Timezone to use for the connection. Default is 'UTC'.

TYPE: str DEFAULT: 'UTC'

auth

Authentication method to use for the connection. Mutually exclusive with password.

TYPE: str DEFAULT: None

match_schema

Regex pattern to filter schemas. Mutually exclusive with match_tables.

TYPE: str DEFAULT: None

match_tables

Regex pattern to filter tables. Mutually exclusive with match_schema.

TYPE: str DEFAULT: None

**kwargs

Additional keyword arguments passed directly to the trino.dbapi.connect API.

TYPE: Any DEFAULT: {}