当前位置: 首页 > 工具软件 > Happy.js > 使用案例 >

happyhbase

况嘉运
2023-12-01

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()

 类似资料:

相关阅读

相关文章

相关问答