HappyBase

raw JSON →
1.3.0 verified Fri May 01 auth: no python

HappyBase is a developer-friendly Python library to interact with Apache HBase, providing a Thrift-based client. Current version is 1.3.0, released in 2023. Release cadence is low, with occasional updates.

pip install happybase
error ModuleNotFoundError: No module named 'thrift'
cause The thrift library is not installed.
fix
pip install thrift
error TTransportException: Could not connect to localhost:9090
cause HBase Thrift server is not running or not reachable.
fix
Start the Thrift server with 'hbase thrift start' or check host/port.
error TypeError: __init__() got an unexpected keyword argument 'port'
cause Using an older version of HappyBase that doesn't accept 'port' directly.
fix
Use 'host' and 'port' via a tuple: Connection(('localhost', 9090)) or upgrade to >=0.9.
breaking HappyBase 1.0+ dropped support for Python 2.7 and older Thrift versions.
fix Upgrade to Python 3.6+ and install thrift>=0.10.
goto HappyBase Connection does not automatically reconnect. If the Thrift server restarts, you must create a new Connection object.
fix Wrap calls in try-except and recreate the connection on failure.
deprecated The 'batch' method's 'walk' parameter is deprecated and will be removed.
fix Use Table.scan() with row_prefix instead of batch(walk=True).

Connects to HBase Thrift server and lists tables.

import os
from happybase import Connection

host = os.environ.get('HBASE_HOST', 'localhost')
port = int(os.environ.get('HBASE_PORT', 9090))
connection = Connection(host=host, port=port)
print(connection.tables())
connection.close()