Parameters | Required | Description |
Source Name | Yes | Customizable. |
Description | No | Customizable. |
IP hostname | Yes | Fill in the IP that can access the engine. For intranet access, you can check it in the DLC console as shown below: ![]() For public network access, you need to enable public network access for the engine first. Please refer to Configuring Public Network Access for the Engine. |
Port | Yes | 10009 |
Username | Yes | Fill in engine id and resource group id, separated by "&". |
Password | Yes | Fill in secretid and secretkey, separated by "&". |
ln -s /usr/bin/python /opt/soft/python
pip install --upgrade tencentcloud-sdk-python
import jsonimport typesfrom tencentcloud.common import credentialfrom tencentcloud.common.profile.client_profile import ClientProfilefrom tencentcloud.common.profile.http_profile import HttpProfilefrom tencentcloud.common.exception.tencent_cloud_sdk_exception import TencentCloudSDKExceptionfrom tencentcloud.dlc.v20210125 import dlc_client, modelsimport base64import timeimport sysdef create_task(sql):global errtry:# Instantiate an authentication object. Pass in the SecretId and SecretKey of your Tencent Cloud account as input parameters and keep the key pair confidential.# Code leakage may lead to the exposure of SecretId and SecretKey, threatening the security of all resources under the account. The following code example is for reference only. It is recommended to use a more secure way to handle the keys. Please refer to: https://cloud.tencent.com/document/product/1278/85305# You can get the keys from the official console at https://console.cloud.tencent.com/cam/capicred = credential.Credential("secretId", "secretKey")# Instantiate an HTTP option, which is optional and can be skipped without specific requirements.httpProfile = HttpProfile()httpProfile.endpoint = "dlc.tencentcloudapi.com"# Instantiate a client option, which is optional and can be skipped without specific requirements.clientProfile = ClientProfile()clientProfile.httpProfile = httpProfile// Instantiate the client object of the requested product. `clientProfile` is optionalclient = dlc_client.DlcClient(cred, "region", clientProfile)// Instantiate a request object. Each API corresponds to a request objectreq = models.CreateTasksRequest()base64sql = base64.b64encode(sql.encode('utf-8')).decode('utf-8')# print(base64sql)# print(base64sql)params = {"DatabaseName": "db","Tasks": {"TaskType": "SQLTask","FailureTolerance": "Terminate","SQL": base64sql,},"DatasourceConnectionName": "DataLakeCatalog","DataEngineName": "engineName"}req.from_json_string(json.dumps(params))// The returned `resp` is an instance of the `CreateTasksResponse` class which corresponds to the request objectresp = client.CreateTasks(req)# A string return packet in JSON format is outputtedprint(resp.to_json_string())return respexcept TencentCloudSDKException as err:print(err)if __name__ == "__main__":try:sql_file = "sql_file_path/dlc.sql"print(sql_file)with open(sql_file, 'r') as file:sqls = file.read()print(sqls)create_rsp = create_task(sqls)except Exception as main_err:print(main_err)
import jaydebeapijdbc_url = "jdbc:dlc:dlc.tencentcloudapi.com?task_type=SQLTask&datasource_connection_name=DataLakeCatalog®ion=ap-guangzhou&data_engine_name=public-engine"user = "xx"pwd = "xx"driver = "com.tencent.cloud.dlc.jdbc.DlcDriver"jar_file = '/opt/dolphinscheduler/libs/dlc-jdbc-2.2.3-jar-with-dependencies.jar'sql = "select 1"conn = jaydebeapi.connect(driver, jdbc_url, [user, pwd], jar_file)curs = conn.cursor()curs.execute(sql)array_size = curs.arraysize.realrowcount = curs.rowcount.realprint(array_size)print(rowcount)rows = curs.rowcount.realif rows != 0:result = curs.fetchall()print(result)curs.close()conn.close()
Parameters | Description |
jdbc_url | |
user | SecretId |
pwd | SecretKey |
dirver | |
jar_file |