hive-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Brad Ruderman <bruder...@radiumone.com>
Subject Hive Server 2 Python Client Drivers
Date Wed, 23 Oct 2013 21:42:43 GMT
Hi All-
I have struggled for awhile with a simple and straightforward driver that I
can use to connect to Hive Server 2 in a very similar manner as a mysql
driver in python. I know there are a few ways like using thrift or ODBC but
all require significant amount of installation. I decided to create my own
package that includes all the required packages such as SASL and Thrift
wrappers to connect. It is called pyhs2 and is avaliable here:

https://github.com/BradRuderman/pyhs2

To use simply:

pip install pyhs2

then:

import pyhs2

conn = pyhs2.connect(host='localhost',
					port=10000,
					authMechanism="PLAIN",
					user='root',
					password='test',
					database='default')
cur = conn.cursor()
cur.execute("show tables")
for i in cur.fetch():
	print i
cur.close()
conn.close()

Feel free to use it, I plan to add additional functionality and fix
any bugs that exist. Most of the code was repurposed from a variety of
sources. I hope you find it useful, please let me know if you have any
questions.


Thanks,

Brad

Mime
View raw message