Alibaba Cloud ADB (AnalyticDB) SDK 20211201

3.7.1 · active · verified Thu Apr 09

The `alibabacloud-adb20211201` library, currently at version 3.7.1, provides the official Python SDK for interacting with Alibaba Cloud AnalyticDB (ADB) services. It allows developers to programmatically manage ADB clusters, databases, and execute various ADB operations. Alibaba Cloud SDKs are typically updated frequently to reflect the latest API changes for their respective services and API versions.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to initialize the `adb20211201` client, configure it with credentials and an endpoint, and then make a basic API call (describing a DB Cluster's attributes). Ensure your `ALIBABA_CLOUD_ACCESS_KEY_ID` and `ALIBABA_CLOUD_ACCESS_KEY_SECRET` environment variables are set, and replace the placeholder `db_cluster_id` and `cn-hangzhou` with your actual values.

import os
from alibabacloud_adb20211201.client import Client
from alibabacloud_adb20211201.models import DescribeDBClusterAttributeRequest
from alibabacloud_tea_openapi.models import Config
from alibabacloud_tea_util.models import RuntimeOptions

# Configure AccessKey ID and Secret from environment variables
config = Config(
    access_key_id=os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID', ''),
    access_key_secret=os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET', '')
)

# IMPORTANT: Configure the correct endpoint for your region and service.
# Replace 'cn-hangzhou' with your actual region.
config.endpoint = 'adb.cn-hangzhou.aliyuncs.com'

# Initialize the ADB client
client = Client(config)

# Example: Describe a DB Cluster Attribute
# Replace 'am-xxxxxxxxx' with an actual ADB cluster ID
request = DescribeDBClusterAttributeRequest(
    db_cluster_id='am-testclusterid'
)

runtime = RuntimeOptions()
try:
    # Make the API call
    response = client.describe_dbcluster_attribute_with_options(request, runtime)
    print("Successfully described DB Cluster attribute:")
    print(response.body.to_map())
except Exception as error:
    print(f"An error occurred: {error}")
    # In a production environment, parse 'error.code' and 'error.message'
    # for more specific error handling.

view raw JSON →