edit-icon download-icon

Example of Python SDK ListTable

Last Updated: Apr 11, 2018

ListTable sample code

  1. # -- coding: utf8 --
  2. import time
  3. import logging
  4. import unittest
  5. from ots2 import *
  6. ENDPOINT = "https://xxx.cn-hangzhou.ots.aliyuncs.com";
  7. ACCESSID = "xxx";
  8. ACCESSKEY = "xxx";
  9. INSTANCENAME = "xxx";
  10. ots_client = OTSClient(ENDPOINT, ACCESSID, ACCESSKEY, INSTANCENAME)
  11. list_response = ots_client.list_table()
  12. print u'instance table:'
  13. for table_name in list_response:
  14. print table_name

Note: For more information about Python SDK, see Python SDK.

The Python SDK documentation does not include information about the import prompt. If import is not added, the following prompt appears.

  1. Traceback (most recent call last):
  2. File "listtable.py", line 6, in
  3. ots_client = OTSClient(ENDPOINT, ACCESSID, ACCESSKEY, INSTANCENAME)
  4. NameError: name 'OTSClient' is not defined

To resolve this issue, you must add import execution as follows.

Add import execution

Thank you! We've received your feedback.