【python 读取hbase数据】happybase 轻松读取hbase数据集

HappyBase是开发人员友好的Python库,可与Apache HBase进行交互。HappyBase设计用于标准HBase设置,并为应用程序开发人员提供了Pythonic API以与HBase进行交互。在表面之下,HappyBase使用Python Thrift库通过其Thrift网关连接到HBase ,该网关包含在标准HBase 0.9x版本中。

这个包非常好用,简单高效读取。

官方文档学习点这里

安装包:

pip install happybase

demo 例子

import happybase

connection = happybase.Connection('192.168.8.xxx',port=9090)
#print(connection.tables())
#DR_RT_OPC_KAFKAAI_KKNF DR_RT_OPC_KAFKAAI_KKNF
table = connection.table('DR_RT_OPC_KAFKAAI_KKNF')

# 读取0120GN01HR01_M这个标签20200715日的数据
for key, data in table.scan(row_prefix=b'0120GN01HR01_M_2020071512'):
    print(str(key,encoding='utf-8'), float(data[b'info:value']))



运行结果:

0120GN01HR01_M_20200715120000 29.78
0120GN01HR01_M_20200715120020 29.8
0120GN01HR01_M_20200715120025 29.78
0120GN01HR01_M_20200715120155 29.83
0120GN01HR01_M_20200715120200 29.8
0120GN01HR01_M_20200715120205 29.78
0120GN01HR01_M_20200715120215 29.72
0120GN01HR01_M_20200715120220 29.83
0120GN01HR01_M_20200715120225 29.78
0120GN01HR01_M_20200715120250 29.72
0120GN01HR01_M_20200715120255 29.78
0120GN01HR01_M_20200715120440 29.8
0120GN01HR01_M_20200715120445 29.78
0120GN01HR01_M_20200715120505 29.8
0120GN01HR01_M_20200715120510 29.78
0120GN01HR01_M_20200715120630 29.8
0120GN01HR01_M_20200715120640 29.78
0120GN01HR01_M_20200715120650 29.8
0120GN01HR01_M_20200715120655 29.78
0120GN01HR01_M_20200715120755 29.8
0120GN01HR01_M_20200715120800 29.78
0120GN01HR01_M_20200715120820 29.8
0120GN01HR01_M_20200715120830 29.78
0120GN01HR01_M_20200715120835 29.8
0120GN01HR01_M_20200715120840 29.78
0120GN01HR01_M_20200715121110 29.86
0120GN01HR01_M_20200715121115 29.8
0120GN01HR01_M_20200715121120 29.78
0120GN01HR01_M_20200715121315 29.8
0120GN01HR01_M_20200715121320 29.78
0120GN01HR01_M_20200715121350 29.8
0120GN01HR01_M_20200715121355 29.78
0120GN01HR01_M_20200715121450 29.8
0120GN01HR01_M_20200715121455 29.78
0120GN01HR01_M_20200715121600 29.72
0120GN01HR01_M_20200715121605 29.8
0120GN01HR01_M_20200715121610 29.78
0120GN01HR01_M_20200715121645 29.8
0120GN01HR01_M_20200715121655 29.78
0120GN01HR01_M_20200715121755 29.8
0120GN01HR01_M_20200715121800 29.78
0120GN01HR01_M_20200715121810 29.8
0120GN01HR01_M_20200715121820 29.78
0120GN01HR01_M_20200715121840 29.72
0120GN01HR01_M_20200715121845 29.8
0120GN01HR01_M_20200715121850 29.72
0120GN01HR01_M_20200715121855 29.78
0120GN01HR01_M_20200715121900 29.8
0120GN01HR01_M_20200715121905 29.72
0120GN01HR01_M_20200715121910 29.78
0120GN01HR01_M_20200715121915 29.72
0120GN01HR01_M_20200715121920 29.78
0120GN01HR01_M_20200715121940 29.8
0120GN01HR01_M_20200715121945 29.78
0120GN01HR01_M_20200715121955 29.8
0120GN01HR01_M_20200715122000 29.78
0120GN01HR01_M_20200715122005 29.8
0120GN01HR01_M_20200715122010 29.78
0120GN01HR01_M_20200715122015 29.72
0120GN01HR01_M_20200715122035 29.8
0120GN01HR01_M_20200715122045 29.78
0120GN01HR01_M_20200715122055 29.67
0120GN01HR01_M_20200715122100 29.78

Process finished with exit code 0

©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页