Call the GetScheduledSQL operation to retrieve a scheduled SQL job.
Note
The Simple Log Service SDK for Scheduled SQL is no longer updated. Use the Alibaba Cloud SDK to manage Scheduled SQL.

Prerequisites
Simple Log Service is activated.
Simple Log Service SDK for Python is initialized.
Parameters
def get_scheduled_sql(self, project_name, job_name):Request parameters
Parameter | Type | Required | Description | Example |
project_name | String | Yes | The name of the project. | demo-test-project |
job_name | String | Yes | The name of an existing scheduled SQL job. | test-001 |
Response parameters
Sample code
import os
from aliyun.log import LogClient
def main():
# This example shows how to obtain an AccessKey ID and an AccessKey secret from environment variables.
accessKeyId = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_ID', '')
accessKey = os.environ.get('ALIBABA_CLOUD_ACCESS_KEY_SECRET', '')
# The Simple Log Service endpoint.
endpoint = "cn-hangzhou.log.aliyuncs.com"
project_name = "demo-test-project"
job_name = "test-001"
client = LogClient(endpoint, accessKeyId, accessKey, "")
res = client.get_scheduled_sql(project_name, job_name)
res.log_print()
if __name__ == '__main__':
main()
Sample response
GetScheduledSqlResponse:
headers: {'Server': 'AliyunSLS', 'Content-Type': 'application/json', 'Content-Length': '971', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*', 'Date': 'Fri, 01 Nov 2024 07:11:52 GMT', 'x-log-time': '1730445112', 'x-log-requestid': '67247F3880283CB6EAA247C6'}
scheduled_sql: {'name': 'test-001', 'type': 'ScheduledSQL', 'apiType': 'ScheduledSQL', 'status': 'ENABLED', 'description': 'Create a scheduled SQL job', 'displayName': 'test-001', 'state': 'Enabled', 'recyclable': False, 'schedule': {'type': 'FixedRate', 'delay': 0, 'interval': '60s', 'runImmediately': False, 'timeZone': '+0800'}, 'configuration': {'roleArn': 'acs:ram::141******5616316:role/aliyunserviceroleforslsaudit', 'destRoleArn': 'acs:ram::141******5616316:role/aliyunserviceroleforslsaudit', 'sourceLogstore': 'test-logstore', 'destEndpoint': 'cn-hangzhou.log.aliyuncs.com', 'destProject': 'demo-test-project', 'destLogstore': 'test-logstore2', 'fromTimeExpr': '@m - 5m', 'toTimeExpr': '@m', 'maxRunTimeInSeconds': 1800, 'maxRetries': 10, 'forceComplete': False, 'fromTime': 1730444541, 'toTime': 0, 'sqlType': 'searchQuery', 'resourcePool': 'enhanced', 'dataFormat': 'log2log', 'version': 0, 'script': '* | select *', 'parameters': {}}, 'scheduleId': 'f3bc8ba5ccb******c68f34ea8fdcf8d', 'createTime': 1730444990, 'lastModifiedTime': 1730444990}
Process finished with exit code 0References
For more information about the API operations used to manage scheduled SQL jobs, see the following topics:
For more sample code, see aliyun-log-python-sdk.