Connect to HBase in Python via HappyBase

Raymond Raymond visibility 2,126 event 2022-03-22 access_time 2 years ago language English
HappyBase is a Python package that can be used to connect to your HBase environment. You can use it easily to insert data, delete data and query data, etc. 


If you don't have a HBase environment to work with, please follow one of the following articles to install HBase:

Install HappyBase package

Use the following command to install HappyBase Python package:

pip install happybase
# or
pip3 install happybase

Connect to HBase

After you installed HBase, make sure you start both HBase service and also thrift service:

bin/ start thrift

By default, the thrift service listens on port 9090.

infoUse sudo if the service doesn't start properly.

Now create a Python script named with the following content:

import happybase
connection = happybase.Connection('',9090)
table = connection.table('test_table')
row = table.row(b'row1')

The scripts connect to the Thrift service in my WSL local HBase standalone instance. Table test_table was created as part of the installation tutorial. 

The output looks like the following screenshot:


It print out value b'value1'.


To learn more about HappyBase package, refer to HappyBase - HappyBase 1.2.0 documentation.

More from Kontext
info Last modified by Raymond 2 years ago copyright This page is subject to Site terms.
comment Comments
No comments yet.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts