Alibaba Cloud TableStore SDK
raw JSON → 6.4.6 verified Fri May 01 auth: no python
The official Python SDK for Alibaba Cloud TableStore (formerly OTS), a distributed NoSQL database. Current version 6.4.6 supports Python >=3.8 and <4.0. Released roughly every few months with backwards compatibility improvements.
pip install tablestore Common errors
error ModuleNotFoundError: No module named 'ots' ↓
cause The package was renamed from 'ots' to 'tablestore' in v4.
fix
Install with 'pip install tablestore' and update imports: 'from tablestore import ...'.
error AttributeError: module 'tablestore' has no attribute 'OTSClient' ↓
cause The symbol 'OTSClient' might have been imported incorrectly. In older docs it was 'ots.OTSClient'.
fix
Use correct import: 'from tablestore import OTSClient'.
error tablestore.error.OTSServiceError: RequestTimeTooSkewed ↓
cause The client machine's clock is not synchronized with Alibaba Cloud servers.
fix
Run NTP sync (e.g., 'sudo ntpdate ntp.aliyun.com') or set correct timezone.
Warnings
breaking Version 4.0 renamed the package from 'ots' to 'tablestore'. All imports must use 'tablestore' instead of 'ots'. ↓
fix Replace 'import ots' with 'import tablestore' and update all references.
breaking In v4+ the client class changed from 'OTSClient' in 'ots' to 'OTSClient' in 'tablestore'. Old code using 'ots.OTSClient' will fail. ↓
fix Use 'from tablestore import OTSClient' instead.
deprecated The 'write_row' method is deprecated in favor of 'put_row' as of v5.0. ↓
fix Replace 'client.write_row(table, row)' with 'client.put_row(table, row)'.
gotcha The SDK requires the 'crcmod' library for data integrity checks. If not installed, clients may silently fall back to a slower Python CRC implementation or raise an import error. ↓
fix Install crcmod: pip install crcmod.
Imports
- OTSClient wrong
from ots import OTSClientcorrectfrom tablestore import OTSClient
Quickstart
from tablestore import OTSClient
endpoint = os.environ.get('OTS_ENDPOINT', '')
access_key_id = os.environ.get('OTS_ACCESS_KEY_ID', '')
access_key_secret = os.environ.get('OTS_ACCESS_KEY_SECRET', '')
instance_name = os.environ.get('OTS_INSTANCE_NAME', '')
client = OTSClient(endpoint, access_key_id, access_key_secret, instance_name)
# List tables
tables = client.list_table()
print(tables)