Versions Compared

Key

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

...

To connect Kyvos using Python, you must have the following.

  1. Python (3 and above) must be hosted either on an analyst’s machine or on Hadoop Cluster (Cloud/On-Premises).

  2. PYODBC module 

  3. Kyvos ODBC installed in the machine, where Python code will execute.

  4. JayDeBeApi module

  5. Hive JDBC Driver

Steps to connect

  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 the Test.py file, use the following script code and make the required changes.

    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.

...