class_docstr: This handler handles connection and execution of the Trino statements
  
  kerberos is not implemented yet
class_docstr_tok: ["This","handler","handles","connection","and","execution","of","the","Trino","statements","kerberos","is","not","implemented","yet"]
docstr: "
  Handles the connection to a Trino instance.
docstr_tok: ["``","Handles","the","connection","to","a","Trino","instance","."]
code: def connect(self):
      """ "
      Handles the connection to a Trino instance.
      """
      if self.is_connected is True:
          return self.connection
  
      # option configuration
      http_scheme = "http"
      auth = None
      auth_config = None
      password = None
  
      if "auth" in self.connection_data:
          auth = self.connection_data["auth"]
      if "password" in self.connection_data:
          password = self.connection_data["password"]
      if "http_scheme" in self.connection_data:
          http_scheme = self.connection_data["http_scheme"]
      if "with" in self.connection_data:
          self.with_clause = self.connection_data["with"]
  
      if password and auth == "kerberos":
          raise Exception(
              "Kerberos authorization doesn't support password."
          )
      elif password:
          auth_config = BasicAuthentication(
              self.connection_data["user"], password
          )
  
      if auth:
          conn = connect(
              host=self.connection_data["host"],
              port=self.connection_data["port"],
              user=self.connection_data["user"],
              catalog=self.connection_data["catalog"],
              schema=self.connection_data["schema"],
              http_scheme=http_scheme,
              auth=auth_config,
          )
      else:
          conn = connect(
              host=self.connection_data["host"],
              port=self.connection_data["port"],
              user=self.connection_data["user"],
              catalog=self.connection_data["catalog"],
              schema=self.connection_data["schema"],
          )
  
      self.is_connected = True
      self.connection = conn
      return conn
  
imports: import re
  from typing import Dict
  import pandas
  from pyhive import trino, sqlalchemy_trino
  from mindsdb_sql import parse_sql, ASTNode
  from trino.auth import KerberosAuthentication, BasicAuthentication
  from trino.dbapi import connect
  from mindsdb_sql.render.sqlalchemy_render import SqlalchemyRender
  from mindsdb.integrations.libs.base import DatabaseHandler
  from mindsdb.utilities import log
  from mindsdb.integrations.libs.response import HandlerStatusResponse, HandlerResponse, RESPONSE_TYPE
  from .trino_config_provider import TrinoConfigProvider
label_desc: Use image node_id 2 for calling the TrinoHandler obj's underlying member method code with example usage: obj.connect() and returns: conn, self