happyhbase

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值