栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 前沿技术 > 大数据 > 大数据系统

happyhbase

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

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/695884.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号