Skip to content

Latest commit

 

History

History
64 lines (47 loc) · 1.52 KB

sdk_guide_python.md

File metadata and controls

64 lines (47 loc) · 1.52 KB

Tera Python SDK Guide

How to Use

  1. Get TeraSdk.py.
  2. Build Tera. See Build.
  3. Add the path of libtera_c.so to the environment variable LD_LIBRARY_PATH.
  4. 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

  1. Synchronous Read
  2. Synchronous and Asynchronous Write
  3. Scan

Implementations

  1. Tera Python SDK uses ctypes library to communicate with libtera_c.so. From V2.3, Python standard libraries bring ctypes library.
  2. 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)