Username and Password Authentication Using HSBroker
This section applies to MRS 3.3.0 or later.
This section describes how to use HSBroker to connect to HetuEngine with the username and password, and assemble and send the SQL statements to HetuEngine for execution.
import jaydebeapi driver = "io.xxx.jdbc.xxxDriver" # need to change the value based on the cluster information url = "jdbc:xxx://192.168.43.223:29860,192.168.43.244:29860/hive/default?serviceDiscoveryMode=hsbroker" user = "YourUserName" // Hard-coded password or plaintext password in code poses significant security risks. Encrypt and store them in configuration files or environment variables and decrypt them when needed. // The password is stored in environment variables for identity authentication. Before running this example, set the environment variable HETUENGINE_PASSWORD. password = os.getenv('HETUENGINE_PASSWORD') tenant = "YourTenant" jdbc_location = "Your file path of the jdbc jar" sql = "show tables" if __name__ == '__main__': conn = jaydebeapi.connect(driver, url, {"user": user, "password": password, "tenant": tenant}, [jdbc_location]) curs = conn.cursor() curs.execute(sql) result = curs.fetchall() print(result) curs.close() conn.close()
The following table describes the parameters in the preceding code.
Parameter |
Description |
---|---|
url |
jdbc:xxx://HSBroker1_IP:HSBroker1_Port,HSBroker2_IP:HSBroker2_Port,HSBroker3_IP:HSBroker3_Port/catalog/schema?serviceDiscoveryMode=hsbroker
NOTE:
|
user |
Username for accessing HetuEngine, that is, the username of the human-machine user created in the cluster. |
password |
Password of the human-machine user created in the cluster. |
tenant |
Tenant resource queue for accessing HetuEngine compute instances |
jdbc_location |
Full path of the hetu-jdbc-XXX.jar package obtained in Configuring the Python3 Sample Project.
|
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot