- 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.
See to TeraSdk.py to get detailed explainations of APIs from the code comments.
- Synchronous Read
- Synchronous and Asynchronous Write
- Scan
- 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.
Python SDK implements the data manipulation operations.
Table management operations should be achieved by teracli
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)
Synchronous write
try:
table.Put("row_key", "column_family", "qualifier", "value")
except TeraSdkException as e:
print(e.reason)
Synchronous read
try:
print(table.Get("row_key", "column_family", "qualifier", 0))
except TeraSdkException as e:
print(e.reason)