Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  1. To download the Hive JDBC Driver, click here.

  2. Save the Driver at any location. For example, /data/hdisk5/put_data/HiveJDBC/hive-jdbc-uber-2.6.5.0-292.jar

  3. To install Python, execute the yum install python3 command if not installed.

  4. To install Pip, execute the curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py command.

  5. To install JayDeBeApi, execute the pip3 install JayDeBeApi command.

  6. Set JAVA_HOME, if not set.

  7. To create Create the Test.py file. To create the file, use the following you need a script code and then make the required changeschanges as needed.
    Following is a sample script code.

    Code Block
    languagepy
    import jaydebeapi
    from contextlib import closing
    
    jclassname='org.apache.hive.jdbc.HiveDriver'
    jdbc_driver_loc = '/data/hdisk5/put_data/HiveJDBC/hive-jdbc-uber-2.6.5.0-292.jar'
    jdbc_driver_name = 'org.apache.hive.jdbc.HiveDriver'
    
    url='jdbc:hive2://<IP Address>:<Port>/;transportMode=http;httpPath=kyvos/sql'
    login="userid"
    pwd="password"
    
    sql = "select    country,    sum(sale_price) as SUM_sale_price from Kyvos_RawDataAccuracyCubes.RawData_CompanysaleSF as rawdata_companysalesf group by country order by country asc limit 10000"
    
    conn = jaydebeapi.connect(jclassname=jdbc_driver_name,
                                      url=url,
                                      driver_args=[login, pwd],
                                      jars=jdbc_driver_loc.split(","))
    
    with closing(conn) as conn:
        with closing(conn.cursor()) as cur:
            cur.execute(sql)
            print(cur.fetchall())
  8. Run the python file by executing the python3 Test.py command.

...