from traceback import format_exc import phoenixdb as pb class Utils(object): def get_db_conn(self, url): """ this function is able to get database connection :param url: Database url :return: database connection """ try: _conn = pb.connect(url, autocommit=True) cr = _conn.cursor() print('get HBase connection success....') return cr, _conn except: try: _conn = pb.connect(url, autocommit=True) cr = _conn.cursor() return cr, _conn except: cr = 'err' _conn = format_exc() print(str(format_exc())) return cr, _conn