Tera Python SDK Guide
November 28, 2016 ยท View on GitHub
How to Use
- Get TeraSdk.py.
- Build Tera. See Build.
- Add the path of libtera_c.so to the environment variable LD_LIBRARY_PATH.
- Write your own application code. See sample.
API Doc
See to TeraSdk.py to get detailed explainations of APIs from the code comments.
Support Features
- Synchronous Read
- Synchronous and Asynchronous Write
- Scan
Implementations
- Tera Python SDK uses ctypes library to communicate with libtera_c.so. From V2.3, Python standard libraries bring ctypes library.
- PythonVM and libtera_c.so have to be binary compatible.
API Examples
Python SDK implements the data manipulation operations.
Table management operations should be achieved by teracli
Client & Table
One Client object is used to communicate to one Tera cluster.
try:
client = Client("./tera.flag", "pysdk_log_prefix")
'''
table "oops" has been created by admin
'''
table = client.OpenTable("oops")
except TeraSdkException as e:
print(e.reason)
Write
Synchronous write
try:
table.Put("row_key", "column_family", "qualifier", "value")
except TeraSdkException as e:
print(e.reason)
Read
Synchronous read
try:
print(table.Get("row_key", "column_family", "qualifier", 0))
except TeraSdkException as e:
print(e.reason)