Prism
v0.3.0
v0.3.0
  • 👋Welcome to Prism!
  • Getting Started
    • Installation
    • Creating your first project
    • Why Prism?
  • Fundamentals
    • PrismProject API
      • PrismProject().run
      • PrismProject().graph
    • Tasks
    • Targets
      • Multiple targets
    • CurrentRun API
      • CurrentRun.ref()
      • CurrentRun.conn()
      • CurrentRun.ctx()
  • Connectors
    • Overview
    • BigQueryConnector
    • PostgresConnector
    • RedshiftConnector
    • SnowflakeConnector
    • TrinoConnector
    • PrestoConnector
  • CLI
    • Command Line Interface
    • graph
    • init
    • run
  • Advanced features
    • Concurrency
    • Logging
    • Callbacks
    • Retries
    • Skipping tasks
  • API Reference
    • prism.task.PrismTask
    • @task(...)
    • @target(...)
    • @target_iterator(...)
    • prism.target.PrismTarget
  • Use Cases
    • Analytics on top of dbt
    • Machine Learning
  • Wiki
    • DAGs
Powered by GitBook
On this page
  • Configuration
  • execute_sql
  1. Connectors

TrinoConnector

PreviousSnowflakeConnectorNextPrestoConnector

Last updated 1 year ago

Configuration

Prism relies on the client to connect your project to a Trino cluster. The DBAPI offers several different authentication mechanisms for creating this connection. As of now, Prism only supports .

The required arguments for the Trino connector are:

  • id: ID for your connector

  • autocommit: toggle whether the connection commits changes to the database after executing. The default is True.

  • host: the hostname of Amazon Redshift cluster.

  • port: the port number of the Amazon Redshift cluster.

  • database: the name of the database to which you want to connect.

  • user: the user name to use for authentication.

  • password: the password to use for authentication

trino_connector = TrinoConnector(
    id="trino_connector_id",
    host=os.environ["TRINO_HOST"],
    http_scheme="https",
    port=os.environ["TRINO_PORT"],
    user=os.environ["TRINO_USER"],
    password=os.environ["TRINO_PASSWORD"],
    catalog=os.environ["TRINO_CATALOG"],
    schema=os.environ["TRINO_SCHEMA"],
)

Under the hood, Prism takes care of parsing the configuration variables and establishing a connection to your Trino cluster.

execute_sql

You can run queries against the Trino cluster using the execute_sql function:

from prism.decorators import task
from prism.runtime import CurrentRun

@task()
def trino_task(self):
    conn = CurrentRun.conn("trino_connector_id")
    data = conn.execute_sql(
        sql="SELECT * FROM table"
    )

Note that when return_type = None, the result will be a list tuples containing the query data.

Trino DBAPI
BasicAuthentication