import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
import happybase
plt.rcParams[‘font.sans-serif’]=[‘SimHei’]
plt.rcParams[‘axes.unicode_minus’]=False
def connectHBase():
# 创建和hbase的连接
connection = happybase.Connection(‘192.168.160.131’)
# 获取hbase中的所有表
print(connection.tables())
# 关闭连接
connection.close()
def scanQuery():
# 创建和hbase的连接
connection = happybase.Connection(‘192.168.160.131’)
# 通过connection找到user表 获得table对象
table = connection.table(‘result_time’)
x_kpi_time=np.zeros((20))
y_kpi_time = np.zeros((20))
i=0
for key, value in table.scan():
line_time=str(key).split('\'')
line_times_temp=str(value).split(':')
line_times=str(line_times_temp[1]).strip('\'')
# print(value)
x_kpi_time[i]=line_time[1]
y_kpi_time[i] = line_times
i = i + 1
print(y_kpi_time)
print(x_kpi_time)
plt.show()
# 关闭连接
connection.close()
def getQuery(a):
connection = happybase.Connection(‘192.168.160.131’)
# 通过connection找到user表 获得table对象
table = connection.table(‘result_time’)
# result = table.row(‘2021012203’)
result = table.row(str(a))
print(result)
# 关闭连接
connection.close()
def main():
connectHBase()
scanQuery()
getQuery(2021012203)
if name == “main”:
main()