Connect to a CDP Data Hub cluster
The Data Connection Snippet feature helps simplify the user experience by abstracting the complexity of creating and configuring a data connection.
You can set up a Data Hub Impala or Hive connection by following the documentation: Set up a data connection to CDP Data Hub.
However, if you would still like to use raw Python code to connect, follow this Python example:
from impala.dbapi import connect #Example connection string: # jdbc:hive2://my-test-master0.eng-ml-i.svbr-nqvp.int.cldr.work/;ssl=true;transportMode=http;httpPath=my-test/cdp-proxy-api/hive USERNAME=os.getenv(HADOOP_USER_NAME) PASSWORD=os.getenv(WORKLOAD_PASSWORD) conn = connect( host = "my-test-master0.eng-ml-i.svbr-nqvp.int.cldr.work", port = 443, auth_mechanism = "LDAP", use_ssl = True, use_http_transport = True, http_path = "my-test/cdp-proxy-api/hive", user = USERNAME, password = PASSWORD) cursor = conn.cursor() cursor.execute("<<INSERT SQL QUERY HERE>>") for row in cursor: print(row) cursor.close() conn.close()