Update the configurations of the Dedicated SQL feature

Updated at:

Call the UpdateSqlInstance API operation to update the Dedicated SQL configurations of a project.

Prerequisites

Parameter description

def update_sql_instance(self, project_name, sql_instance,useAsDefault):

Request parameters

Parameter

Type

Required

Description

Example

project_name

String

Yes

The name of the project for which you want to enable the Dedicated SQL feature.

demo-test-project

sql_instance

int

Yes

The number of compute units (CUs). CUs are used in parallel when the Dedicated SQL feature is enabled.

800

useAsDefault

bool

Yes

Specifies whether to enable the Dedicated SQL feature for the project. If set to true, the feature takes effect for all query statements in the project, including those for alerts and dashboards.

False

Sample code

from aliyun.log import LogClient
import os


def main():
    # The Simple Log Service endpoint. For more information, see Endpoints. In this example, the Simple Log Service endpoint for the China (Hangzhou) region is used. Replace the parameter value with the actual endpoint.
    endpoint = 'cn-hangzhou.log.aliyuncs.com'
    # In this example, the AccessKey ID and AccessKey secret are obtained from environment variables.
    access_key_id = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID', '')
    access_key = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET', '')
    # The name of the project.
    project_name = 'demo-test-project'

    # Create a Simple Log Service client.
    client = LogClient(endpoint, access_key_id, access_key)

    # Modify the configurations of the SQL instance. You can change the number of CUs for the SQL instance. Valid values: 0 to 1000.
    print("===sample_update_sql_instance===")
    res = client.update_sql_instance(project_name, 800, False)
    res.log_print()

    # Obtain the configurations of the SQL instance.
    print("===sample_list_sql_instance===")
    res = client.list_sql_instance(project_name)
    res.log_print()


if __name__ == '__main__':
    main()

Sample response

===sample_update_sql_instance===
UpdateSqlInstanceResponse:
request_id: 6729B7475893C82A6F3024CD
headers: {'Server': 'AliyunSLS', 'Content-Length': '0', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*', 'Date': 'Tue, 05 Nov 2024 06:12:25 GMT', 'x-log-time': '1730787145', 'x-log-requestid': '6729B7475893C82A6F3024CD'}
response: 
===sample_list_sql_instance===
ListSqlInstanceResponse:
request_id: 6729B749ACB7203E32D79EEA
headers: {'Server': 'AliyunSLS', 'Content-Type': 'application/json', 'Content-Length': '152', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*', 'Date': 'Tue, 05 Nov 2024 06:12:25 GMT', 'x-log-time': '1730787145', 'x-log-requestid': '6729B749ACB7203E32D79EEA'}
response: [{'createTime': 1730786020, 'cu': 800, 'name': 'group1', 'updateTime': 1730787143, 'useAsDefault': False}]

Process finished with exit code 0