No project description provided
Project description
hbase-driver
Native Hbase driver in Python. (No thrift)
Introduction
- written in pure Python
- native HBase protocol support (HBase 2.X+)
- Support both admin operations and regionserver calls.
Installation (pip)
pip3 install hbase-driver
Get Started
import time
from hbasedriver.client import Client
from hbasedriver.operations import Put, Get, Scan, Delete
from hbasedriver.exceptions.RemoteException import TableExistsException
from hbasedriver.operations.column_family_builder import ColumnFamilyDescriptorBuilder
# lets say your hbase instance runs on 127.0.0.1 (zk quorum address)
client = Client(["127.0.0.1"])
# Define column families
cf1_builder = ColumnFamilyDescriptorBuilder(b"cf1")
cf1_builder.set_compression_type(b"SNAPPY")
cf1_builder.set_max_versions(5)
cf1_builder.set_time_to_live(86400)
cf1_builder.set_block_size(65536)
cf1_descriptor = cf1_builder.build()
cf2_builder = ColumnFamilyDescriptorBuilder(b"cf2")
cf2_builder.set_compression_type(b"LZO")
cf2_builder.set_max_versions(3)
cf2_builder.set_time_to_live(3600)
cf2_builder.set_block_size(32768)
cf2_descriptor = cf2_builder.build()
column_families = [cf1_descriptor, cf2_descriptor]
try:
client.create_table(b"", b"test_table_master", column_families, split_keys=[b"111111", b"222222", b"333333"])
except TableExistsException:
pass
table = client.get_table("", "mytable")
# put
table.put(Put(b'row1').add_column(b'cf1', b'qf', b'666'))
table.put(Put(b'row1').add_column(b'cf1', b'qf2', b'999'))
table.put(Put(b'row1').add_column(b'cf2', b'qf', b'777'))
table.put(Put(b'row2').add_column(b'cf1', b'qf123', b'777'))
# get
result = table.get(Get(b"row1").add_column(b'cf1', b'qf'))
print("get result =", result)
assert b'666' == result.get(b'cf1', b'qf')
# scan
scan_result = table.scan(Scan(b"row1").add_family(b'cf1'))
# retrieve all results from the iterator.
scan_result = list(scan_result)
print("scan result below:")
for row in scan_result:
print(row)
# delete
table.delete(Delete(b"row1")) # this will delete the whole row
# check cf deleted
result = table.get(Get(b"row1").add_column(b'cf1', b'qf'))
assert result is None
# disable table
client.master_conn.disable_table(None, b"mytable")
time.sleep(1)
client.master_conn.delete_table(None, b"mytable")
Master (metadata) operations
from hbasedriver.client import Client
client = Client(["127.0.0.1"])
# describe table
res = client.describe_table(b'', b"mytable")
print(res)
# table_name {
# namespace: "default"
# qualifier: "test_table_master"
# }
# attributes {
# first: "IS_META"
# second: "false"
# }
# attributes {
# first: "hbase.store.file-tracker.impl"
# second: "DEFAULT"
# }
# column_families {
# name: "cf1"
# attributes {
# first: "INDEX_BLOCK_ENCODING"
# second: "NONE"
# }
# ..........
Implemented
- Create, Disable, Delete table
- Put
- Get
- DELETE
- Scan
TODOs
- Filters
- More params in the operations.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
hbase_driver-1.0.1.tar.gz
(120.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
hbase_driver-1.0.1-py3-none-any.whl
(174.6 kB
view details)
File details
Details for the file hbase_driver-1.0.1.tar.gz.
File metadata
- Download URL: hbase_driver-1.0.1.tar.gz
- Upload date:
- Size: 120.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
430dbd214ea1d32059430683a4c730818ac11b9c579cd3317a5655bd26f54a37
|
|
| MD5 |
c3d8557ca2da7b2683a276eee8f434b8
|
|
| BLAKE2b-256 |
3c1ff92f8096234ffdedf888452985ee9de1a0d4767a3c90c178bf29e9c0b7c5
|
File details
Details for the file hbase_driver-1.0.1-py3-none-any.whl.
File metadata
- Download URL: hbase_driver-1.0.1-py3-none-any.whl
- Upload date:
- Size: 174.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d8292dec2cc788038cde605da60271cafe8c18156883683490e3cea03228f241
|
|
| MD5 |
502ed5f89605727476dd4dadbce0ef7b
|
|
| BLAKE2b-256 |
b46f5ae4d0a1f026be4ca63da8f039f850fa0e6d6b4dd781e44cac2344d15c90
|