pythonpysparkhive

How to connect a remote Hive server from using JDBC and SSL?


I have below JDBC URL of Hive where I am able to connect from Beeline. I want to know how I can connect to same Hive server using Python.

Below is the command I am using from Beeline to connect to Hive:

jdbc:hive2://park-main-testthrift-lab001.ibe400.****.com:443/default;ssl=true;sslTrustStore=/opt/bitnami/spark/jkscertsconvert/truststore.jks;trustStorePassword=changeit

Solution

  • I am able to find a solution for this

    from hivejdbc import connect
    
    conn = connect(host='park-main-testthrift-lab001.ibe400.****.com',
                   port=443,
                   database='default',
                   driver='hive-client-2.3.7-hdfs-2.9.1-aio.jar', #replace path with hive fat jar file path location
                   ssl=True,
                   trust_store='truststore.jks', #replace path with your .jks file path
                   trust_password='changeit')
    
    cursor = conn.cursor()
    cursor.execute("select * from table")