All Products
Search
Document Center

Lindorm:Use the ApsaraDB for HBase API for a non-Java language to develop applications

Last Updated:Mar 28, 2026

LindormTable supports the HBase Thrift2 API, letting you connect from non-Java languages including Python, Go, C++, node.js, and PHP. This topic describes how to set up the Thrift client and connect to LindormTable.

Prerequisites

Before you begin, ensure that you have:

How it works

LindormTable's Thrift server uses HTTP as the transport layer. This differs from the default TSocket transport in standard Thrift setups, so your client must use THttpClient rather than the usual socket-based transport.

To connect:

  1. Use the thrift compiler to generate client stubs from hbase.thrift in your target language.

  2. Create a THttpClient instance pointing to your LindormTable endpoint.

  3. If Access Control List (ACL) authentication is enabled on your instance, pass your username and password as HTTP request headers (ACCESSKEYID and ACCESSSIGNATURE). If ACL is disabled, skip the headers.

  4. Open the transport, use the client, then close the transport.

Connect to LindormTable using Python

Step 1: Install dependencies and generate client stubs

Install the Thrift Python library:

pip install thrift

Generate the Python client stubs from hbase.thrift. The py argument targets Python:

thrift --gen py hbase.thrift
The thrift --gen command accepts the following language arguments: python, py (Python), php (PHP), cpp (C++). For a full list, see the Apache Thrift documentation.

Step 2: Create a client and connect

The following example creates a THttpClient, optionally sets ACL authentication headers, and opens the connection:

# -*- coding: utf-8 -*-

# Installed via: pip install thrift
from thrift.protocol import TBinaryProtocol
from thrift.transport import THttpClient

# Generated via: thrift --gen py hbase.thrift
from hbase import THBaseService
from hbase.ttypes import (
    TColumnValue, TColumn, TTableName, TTableDescriptor,
    TColumnFamilyDescriptor, TNamespaceDescriptor,
    TGet, TPut, TScan
)

# Replace with the endpoint from the Lindorm console (Wide Table Engine tab,
# "Access by Using HBase non-Java API" section). Port is 9190.
url = "http://ld-bp17j28j2y7pm****-proxy-lindorm.lindorm.rds.aliyuncs.com:9190"

transport = THttpClient.THttpClient(url)

# If ACL is enabled on your LindormTable instance, set authentication headers.
# If ACL is disabled, remove the three lines below.
headers = {}
headers["ACCESSKEYID"] = "<your-username>"
headers["ACCESSSIGNATURE"] = "<your-password>"
transport.setCustomHeaders(headers)

protocol = TBinaryProtocol.TBinaryProtocolAccelerated(transport)
client = THBaseService.Client(protocol)

transport.open()

# Use the client here to perform get, put, scan, and other operations.

transport.close()

Replace the following placeholders with your actual values:

PlaceholderDescription
<your-username>LindormTable username. Required if ACL is enabled.
<your-password>Password for the username. Required if ACL is enabled.

Sample code for other languages

Complete, runnable sample code for each supported language is available on GitHub. Each repository includes connection setup, ACL authentication, and basic put, get, and scan operations:

All examples use THttpClient for the transport layer and set the ACCESSKEYID and ACCESSSIGNATURE headers for ACL authentication.