需要安装pyhs2,其余安装和python3的依赖包差不多,少一个pyhive
# coding: u8
import pyhs2
from pyhs2.error import Pyhs2Exception
class Row(dict):
"""A dict that allows for object-like property access syntax."""
def __getattr__(self, name):
try:
return self[name]
except KeyError:
raise AttributeError(name)
class Connection(object):
def __init__(self, db_host, user, database, port=10000,
authMechanism="PLAIN"):
"""
create connection to hive server2
"""
self.conn = pyhs2.connect(host=db_host,
port=port,
authMechanism=authMechanism,
user=user,
database=database,
)
def query(self, sql):
"""Returns a row list for the given query and parameters."""