Tencent Cloud MariaDB SDK for Python
raw JSON → 3.1.40 verified Sat May 09 auth: no python
Official Tencent Cloud SDK for accessing MariaDB services via the API. Current version 3.1.40, stable release. The SDK follows a predictable pattern per service, with package names mapping to `tencentcloud.${service}.${version}`.
pip install tencentcloud-sdk-python-mariadb Common errors
error ImportError: cannot import name 'MariadbClient' from 'tencentcloud.mariadb' ↓
cause Missing API version in import path.
fix
Use from tencentcloud.mariadb.v20170312 import mariadb_client
error tencentcloud.exception.TencentCloudSDKException: [FailedOperation] The request has been cancelled ↓
cause Expired or invalid credentials.
fix
Verify that TENCENTCLOUD_SECRET_ID and TENCENTCLOUD_SECRET_KEY environment variables are correct and not expired.
Warnings
gotcha The import path includes the API version number. Using an incorrect version may lead to missing methods or attributes. ↓
fix Always use the versioned import path: `from tencentcloud.mariadb.v20170312 import ...`
gotcha Credential environment variables are `TENCENTCLOUD_SECRET_ID` and `TENCENTCLOUD_SECRET_KEY`. Do not use the older `SECRET_ID` or `SECRET_KEY` prefixes. ↓
fix Set environment variables with `TENCENTCLOUD_` prefix or use the `Credential` constructor directly.
deprecated Using `to_json_string()` on response objects is deprecated in newer SDK versions; prefer direct attribute access or the `__dict__` method. ↓
fix Access response attributes directly, e.g., `resp.TotalCount` instead of `resp.to_json_string()` if only specific fields are needed.
Imports
- MariadbClient wrong
from tencentcloud.mariadb import MariadbClientcorrectfrom tencentcloud.mariadb.v20170312 import mariadb_client - models wrong
from tencentcloud.mariadb import modelscorrectfrom tencentcloud.mariadb.v20170312 import models
Quickstart
import os
from tencentcloud.common import credential
from tencentcloud.mariadb.v20170312 import mariadb_client, models
# Replace with your credentials or use environment variables
cred = credential.Credential(
os.environ.get('TENCENTCLOUD_SECRET_ID', ''),
os.environ.get('TENCENTCLOUD_SECRET_KEY', '')
)
client = mariadb_client.MariadbClient(cred, 'ap-guangzhou')
req = models.DescribeDBInstancesRequest()
req.Limit = 10
resp = client.DescribeDBInstances(req)
print(resp.to_json_string())