PrestoConnector
Configuration
Prism relies on the Presto DBAPI client to connect your project to a Presto cluster. The DBAPI offers several different authentication mechanisms for creating this connection. As of now, Prism only supports BasicAuthentication.
The required arguments for the Presto connector are:
id: ID for your connectorautocommit: toggle whether the connection commits changes to the database after executing. The default isTrue.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
presto_connector = PrestoConnector(
id="presto_connector_id",
host=os.environ["PRESTO_HOST"],
http_scheme="https",
port=os.environ["PRESTO_PORT"],
user=os.environ["PRESTO_USER"],
password=os.environ["PRESTO_PASSWORD"],
catalog=os.environ["PRESTO_CATALOG"],
schema=os.environ["PRESTO_SCHEMA"],
)Under the hood, Prism takes care of parsing the configuration variables and establishing a connection to your Trino cluster.
execute_sql
execute_sqlYou can run queries against the Trino cluster using the execute_sql function:
from prism.decorators import task
from prism.runtime import CurrentRun
@task()
def presto_task(self):
conn = CurrentRun.conn("presto_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.
Last updated