Raymond Raymond / Hadoop, Hive & HBase

Connect to HBase in Python via HappyBase

event 2022-03-22 visibility 2,780 comment 0 insights toc
insights Stats
Connect to HBase in Python via HappyBase
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/hbase-daemon.sh 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 test-hbase.py 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
comment Comments
No comments yet.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts