Connect to HBase in Python via HappyBase

visibility 121 access_time 3 months ago languageEnglish timeline 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. 

Prerequisites

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-hbase.sh
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('127.0.0.1',9090)
table = connection.table('test_table')
row = table.row(b'row1')
print(row[b'cf:a'])

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'.

References

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


info Last modified by Raymond 3 months ago copyright This page is subject to Site terms.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts

More from Kontext
pre-commit
visibility 72
thumb_up 1
access_time 4 months ago
Load JSON File into BigQuery
visibility 2,749
thumb_up 0
access_time 2 years ago
Load JSON File into BigQuery