Skip to main content

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

  1. 打包发至私有pypi

2022-4-22

  1. 修复安装后无法使用的bug

2022-5-5

  1. 构造函数增加配置文件路径参数并修改相关内容
  2. 构造函数逻辑优化
  3. 增加简单测试用例
  4. 优化代码格式

2022-5-13

  1. 构造函数优化,默认port为9090,新增配置文件警告

2022-9-8

  1. 调整连接池默认参数,适配hbase 2.0版本连接

2022-10-10

  1. 优化insert函数,新增bytes类型判断与转换
  2. 优化insert_df函数

2022-11-15

  1. 优化__init__, 加入环境判断

2022-11-17

  1. 调整thrift, thrift-sasl版本依赖

2023-02-11

  1. 调整prd参数

2023-02-13

  1. 去除thriftpy依赖

Metadata

Release files for bmai-dm-hbase 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for bmai-dm-hbase 0.2.2
File Size Uploaded Provenance Actions
bmai-dm-hbase-0.2.2.linux-x86_64.tar.gz 10.2 kB Without provenance Details for bmai-dm-hbase-0.2.2.linux-x86_64.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for bmai-dm-hbase 0.2.2
File Interpreter ABI Platform Actions
bmai_dm_hbase-0.2.2-py3-none-any.whl Python 3 none any Details for bmai_dm_hbase-0.2.2-py3-none-any.whl

Total release size: 18.6 kB

Release files / bmai-dm-hbase-0.2.2.linux-x86_64.tar.gz

Download URL bmai-dm-hbase-0.2.2.linux-x86_64.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5dedda2efbbd2eee38e84ba8822f6a1d659f6d9a564cd9bb8e8938790f6ee36d
BLAKE2b-256 checksum
How to use checksums
3a718ca8d87ab9e17a3d7527a80b99a2d38c17895e294e2ea5afb5584c10f3ab
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.7.12

Release files / bmai_dm_hbase-0.2.2-py3-none-any.whl

Download URL bmai_dm_hbase-0.2.2-py3-none-any.whl
Size 8.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
398be9bc680a597f8a074adc7e550bcafd5bc7aeb89527e8feec3c891efed0ea
BLAKE2b-256 checksum
How to use checksums
d62de329c21472de8abd4fbe969dbe3a9782a83671529082f4e46c5aed7a2ae7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.7.12

Security for bmai-dm-hbase 0.2.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page