本文介绍云数据库 veDB MySQL 版 Python SDK 的代码示例供您参考。
使用 SDK 调用 veDB MySQL 接口时,默认无超时时间限制。您可以在发起接口调用请求时,在代码的最后加上 _request_timeout
参数指定请求的超时时间(单位:秒),若未在该时间内完成,请求会立即终止并报超时错误。例如,您可以在调用 DescribeDBInstanceDetail 接口时,通过以下代码设置超时时间为 10 秒。
req = volcenginesdkvedbm.DescribeDBInstanceDetailRequest( instance_id="your instance id" ) resp = client.describe_db_instance_detail(req, _request_timeout=10) # vcpu的返回值有问题
以下示例中参数的详细说明请参见 CreateDBInstance。
def create_db_instance(): client = init_client() req = volcenginesdkvedbm.CreateDBInstanceRequest( charge_type="PostPaid", db_engine_version="MySQL_8_0", db_time_zone="UTC +08:00", instance_name="your instance name", lower_case_table_names="0", node_number=2, node_spec="vedb.mysql.x4.large", subnet_id="your subnet id", super_account_name="your super account name", super_account_password="your super account password", vpc_id="your vpc id", zone_ids="cn-beijing-b", ) resp = client.create_db_instance(req) print(resp)
def describe_db_instance_detail(): client = init_client() req = volcenginesdkvedbm.DescribeDBInstanceDetailRequest( instance_id="your instance id" ) resp = client.describe_db_instance_detail(req) print(resp)