#coding=utf-8
import happybase
port = xxxxxx
host = xxxxxx
class HbaseConPool(object):
'''hbase连接池'''
def __init__(self):
'''
Constructor
'''
self.pool = happybase.ConnectionPool(size=20,host=xxx,port=xxx,timeout=60000*2)
def __new__(cls,*args,**kwargs):
'''
'''
if not hasattr(cls,'_inst'):
cls._inst=super(HbaseConPool,cls).__new__(cls,*args,**kwargs)
return cls._inst
# def createHbaseConPool(self):
# pool = happybase.ConnectionPool(5,host=constant.HBASE_HOST,port=constant.HBASE_PORT)
&nbs
import happybase
port = xxxxxx
host = xxxxxx
class HbaseConPool(object):
'''hbase连接池'''
def __init__(self):
'''
Constructor
'''
self.pool = happybase.ConnectionPool(size=20,host=xxx,port=xxx,timeout=60000*2)
def __new__(cls,*args,**kwargs):
'''
'''
if not hasattr(cls,'_inst'):
cls._inst=super(HbaseConPool,cls).__new__(cls,*args,**kwargs)
return cls._inst
# def createHbaseConPool(self):
# pool = happybase.ConnectionPool(5,host=constant.HBASE_HOST,port=constant.HBASE_PORT)
&nbs

该篇博客介绍了如何使用Python的happybase库创建HBase连接池,并进行数据的插入操作。通过定义`HbaseConPool`类实现连接池管理,提供`get_conn`方法获取连接,以及`close`方法关闭连接。示例代码展示了如何向HBase表中批量及单条插入数据。
最低0.47元/天 解锁文章
1077

被折叠的 条评论
为什么被折叠?



