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:
Downloaded the Thrift 0.12.0 installation package and compiled the
thriftcommand-line toolDownloaded the Thrift2 definition file for ApsaraDB for HBase (
hbase.thrift)Retrieved the LindormTable endpoint from the Access by Using HBase non-Java API section on the Wide Table Engine tab in the Lindorm console. For more information, see View endpoints.

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:
Use the
thriftcompiler to generate client stubs fromhbase.thriftin your target language.Create a
THttpClientinstance pointing to your LindormTable endpoint.If Access Control List (ACL) authentication is enabled on your instance, pass your username and password as HTTP request headers (
ACCESSKEYIDandACCESSSIGNATURE). If ACL is disabled, skip the headers.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 thriftGenerate the Python client stubs from hbase.thrift. The py argument targets Python:
thrift --gen py hbase.thriftThethrift --gencommand 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:
| Placeholder | Description |
|---|---|
<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.