Data mining Group hbase utils
Project description
hbase连接
基于happybase封装简单的hbase使用库,支持连接、创建、查询、插入功能
项目结构
- hbase
- LICENSE.md
- README.md
- setup.py
- src
- __init__.py
- conf_reader.py
- hbase_client.py
- reconection.py
使用方法
安装/更新
# 安装
pip install --index-url http://192.168.38.1:31410/bmai/pypi --trusted-host 192.168.38.1 bmai-dm-hbase
# 更新
pip install --index-url http://192.168.38.1:31410/bmai/pypi --trusted-host 192.168.38.1 bmai-dm-hbase --upgrade
配置文件模板
hbase节点信息
可配可不配,不配置的话直接使用hbase_client.py内的类,自行传入相关信息即可
pro: # 正式环境ec, thrift
host: 192.168.xx.xx # 失效
port: 9090
dev: # 开发环境, thrift
host: 192.168.xx.xx
host_name: xx-xx-xx
port: 9090
示例
import pandas as pd
from dm_hbase.hbase_client import HBaseClient
connection = HBaseClient(
host='xxx.xxx.xx.xx',
port=9090,
env='test' # 2022-11-15新增, env参数支持'test'或者'prd', 默认为'test'
)
connection.build_pool()
# 查看当前库中所有表
connection.show_tables()
# 查表
connection.scan_tables(
table_name='xxx:xxxx',
limit=10
)
# 查列族
connection.get_families('xxx:xxxx')
# 查分区
connection.get_regions('xxx:xxx')
# 插入数据
connection.insert(
table_name='xxx:xxx',
datas={row_key: {'column_family:feature': value}}
batch_size=1000
)
# 以dataframe形式插入数据
df = pd.read_csv('xxx.csv')
connection.insert_df(
table_name='xxx:xxx',
df=df,
rowkeys_col='xxx',
batch_size=1000
)
开发日志
2022-4-21
- 打包发至私有pypi
2022-4-22
- 修复安装后无法使用的bug
2022-5-5
- 构造函数增加配置文件路径参数并修改相关内容
- 构造函数逻辑优化
- 增加简单测试用例
- 优化代码格式
2022-5-13
- 构造函数优化,默认port为9090,新增配置文件警告
2022-9-8
- 调整连接池默认参数,适配hbase 2.0版本连接
2022-10-10
- 优化insert函数,新增bytes类型判断与转换
- 优化insert_df函数
2022-11-15
- 优化__init__, 加入环境判断
2022-11-17
- 调整thrift, thrift-sasl版本依赖
2023-02-11
- 调整prd参数
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Close
Hashes for bmai-dm-hbase-0.2.1.linux-x86_64.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b52bc597ade03de0b36aa39cae48b53318774cf22cf532e9b1817207acafcb7 |
|
MD5 | ebcbec52e794414ffac5ef3e9cf9568f |
|
BLAKE2b-256 | 47ce06b5a06b99bfaca8dfbe75e76731bfe94c20c25f3f905a45516ce0bf7687 |
Close
Hashes for bmai_dm_hbase-0.2.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54203851f4523ec55f83dc8083927ba732a25ea2e0f244abe11c3a3511b907cc |
|
MD5 | 8f85d365f66a0e3fbd78f3c45e15902b |
|
BLAKE2b-256 | 7878f17389c4b32bc225db5d4de3fcd679c8d1e5e5f43427667a4a5812cbb052 |