设为首页 加入收藏

TOP

Python 连接 Hbase happybase
2019-03-05 01:43:14 】 浏览:392
Tags:Python 连接 Hbase happybase

1. 安装thrift

brew install thrift

2.启动thrift

./hbase-daemon.sh start thrift

3.安装依赖python

pip install thrift
pip install hbase-thrift
pip install happybase

这边用的是happybase 这个库,https://happybase.readthedocs.io/en/latest/user.html 去这了解更多。

import happybase
#连接
connection = happybase.Connection('localhost')
connection.open()

# connection.create_table('mytable', {'name' : dict(max_versions=5), 'course':dict()})
#打印所有的表
print(connection.tables())
table = connection.table('Score')
row = table.row(b'95001')
print(row[b'course:Math'])

#插入数据
table.put(b'95002', {b'course:Math':b'65', b'course:English':b'77'})

http://www.codeblogbt.com/archives/146821

】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇深入理解HBase Memstore 下一篇关于hbase应用的一些看法

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目