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.disable_table(None, b"mytable")
time.sleep(1)
client.master.delete_table(None, b"mytable")
Master (metadata) operations
from hbasedriver.client import Client
client = Client(["127.0.0.1"])
# describe table
res = client.master.describe_table(None, "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-0.0.13.tar.gz
(102.2 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-0.0.13-py3-none-any.whl
(148.9 kB
view details)
File details
Details for the file hbase-driver-0.0.13.tar.gz.
File metadata
- Download URL: hbase-driver-0.0.13.tar.gz
- Upload date:
- Size: 102.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
31a4e061930b4a2caeb05e18c5b8f32517385b523a068eee3e7c61c5ba2f24d9
|
|
| MD5 |
d16aa1e0a4aa10ba8b62c44e18b2fc02
|
|
| BLAKE2b-256 |
5bfd9972bb2b94b8e6eca8c79e51089a8d9ed37d50dda7faa1d18627b6b18491
|
File details
Details for the file hbase_driver-0.0.13-py3-none-any.whl.
File metadata
- Download URL: hbase_driver-0.0.13-py3-none-any.whl
- Upload date:
- Size: 148.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.11.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8aa18747193deb38ab07157c86abb734a10bcfaa3d8330cefc02d108bd4915a
|
|
| MD5 |
5a5916fd76004387fa018a24e9e3c883
|
|
| BLAKE2b-256 |
b738d177f6cf0aa53d6e6f100a4018e10c83953460b6060ccae965d5d2cfae9b
|