代码样例
import pyhs2
# PLAIN
with pyhs2.connect(host='n5.cluster',
port=10000,
authMechanism="PLAIN",
user='hive',
password='hive',
database='default') as conn:
with conn.cursor() as cur:
#Show databases
print cur.getDatabases()
#Execute query
cur.execute("select * from table")
#Return column info from query
print cur.getSchema()
#Fetch table results
for i in cur.fetch():
print i
import pyhs2
# KERBEROS
conn = pyhs2.connect(host='n5.cluster',
port=10000,
authMechanism="KERBEROS")
conn = pyhs2.connect(host='n5.cluster',
port=10000,
authMechanism="KERBEROS",
user='xwtech/n5.cluster@EXAMPLE.COM',
configuration={'krb_host': 'n5.cluster', 'krb_service': 'hive'})
pyhs2地址
https://github.com/BradRuderman/pyhs2/