from pyhive import hive import traceback class Hive_tool: def __init__(self): self.conn = hive.Connection(host="******", port=1****, database='ods') self.cur = self.conn.cursor() def execute(self, sql): try: if sql: self.cur.execute(sql) result = self.cur.fetchall() return result except: traceback.print_exc() finally: self.cur.close() self.conn.close()