Created 10-30-2017 05:52 AM
connect hive running on remote host using python with username pwd like we connect in hive-view2.0.
Created 10-30-2017 06:27 AM
I have not tested the following on my own but looks like you can try the following kind of Python Scripts (Utilities) to connect to a remote Hive with username & password:
https://github.com/CERT-BDF/TheHive4py
https://github.com/dropbox/PyHive
.
Created 10-30-2017 06:30 AM
Additionally:
Additionally there is a Python Driver available as per the Doc: https://cwiki.apache.org/confluence/display/Hive/HiveServer2+Clients#HiveServer2Clients-PythonClient
Python Client Driver
https://cwiki.apache.org/confluence/display/Hive/Setting+Up+HiveServer2#SettingUpHiveServer2-PythonC...
Created 10-30-2017 06:48 AM
I found all these by googling but
1) pyhs2 - discontinued
2) pyHive- cant find an example to connect remote host using username/pwd ( not ldap)
can u show be an example code of how to connect to remote hive host using python.
Created 10-31-2017 05:26 AM
I couldnt use pyHive.
however I was able to use pyhs2. If you are getting any errors like {Error in sasl_client_start (-4) SASL(-4): no mechanism available: No worthy mechs found}, then make sure u have installed cyrus-sasl-plain
yum install cyrus-sasl-plain
Created 10-31-2017 06:15 AM
ok after going through the source code of PyHive, I understood that pip install PyHive install a different code than the one at https://github.com/dropbox/PyHive (even though the version are the same)
1) so I uninstalled previous version of pyhive
2) downloaded the souce from https://github.com/dropbox/PyHive and installed this
3) now im able to connect to remote hive using username/password
---- code -----
from pyhive import hive conn = hive.Connection(host="<host>", port=10000, username="<username>", password="<your pwd>", auth='CUSTOM') cur = conn.cursor() cur.execute('select * from <table>'); print cur.fetchone()