...
To connect Kyvos using Python, you must have the following.
Python (3 and above) must be hosted either on an analyst’s machine or on Hadoop Cluster (Cloud/On-Premises).
PYODBC module
Kyvos ODBC installed in the machine, where Python code will execute.
JayDeBeApi module
Hive JDBC Driver
Steps to connect
...
To download the Hive JDBC Driver, click here.
Save the Driver at any location. For example, /data/hdisk5/put_data/HiveJDBC/hive-jdbc-uber-2.6.5.0-292.jar
To install Python, execute the yum install python3 command if not installed.
To install Pip, execute the curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py command.
To install JayDeBeApi, execute the pip3 install JayDeBeApi command.
Set JAVA_HOME, if not set.
To create the Create a Python file that contains the script code used to run the query.
For example, Test.py file, use the following script code and make the is a sample file to demonstrate how to create a file and use a script code. In the script code, you can make required changes.
Following is a sample script code.Code Block language py 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())
Run the python file by executing the python3 Test.py command.
...
panelIconId | atlassian-note |
---|---|
panelIcon | :note: |
bgColor | #DEEBFF |
<name of the file> command. For example, the command would be python3 Test.py