GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing dolphinscheduler.apache.org — Datax — apache-dolphinscheduler 4.1.0-dev documentation DataxA DataX task type’s example and dive into information of PyDolphinScheduler. Example""" A example workflow for task datax. This example will create a workflow named `task_datax`. `task_datax` is true workflow define and run task task_datax. You can create data sources `first_mysql` and `first_mysql` through UI. It creates a task to synchronize datax from the source database to the target database. """ import json from pydolphinscheduler.core.workflow import Workflow from pydolphinscheduler.tasks.datax import CustomDataX, DataX # datax json template JSON_TEMPLATE = { "job": { "content": [ { "reader": { "name": "mysqlreader", "parameter": { "username": "usr", "password": "pwd", "column": ["id", "name", "code", "description"], "splitPk": "id", "connection": [ { "table": ["source_table"], "jdbcUrl": ["jdbc:mysql://127.0.0.1:3306/source_db"], } ], }, }, "writer": { "name": "mysqlwriter", "parameter": { "writeMode": "insert", "username": "usr", "password": "pwd", "column": ["id", "name"], "connection": [ { "jdbcUrl": "jdbc:mysql://127.0.0.1:3306/target_db", "table": ["target_table"], } ], }, }, } ], "setting": { "errorLimit": {"percentage": 0, "record": 0}, "speed": {"channel": 1, "record": 1000}, }, } } with Workflow( name="task_datax_example", ) as workflow: # This task synchronizes the data in `t_ds_project` # of `first_mysql` database to `target_project` of `second_mysql` database. # You have to make sure data source named `first_mysql` and `second_mysql` exists # in your environment. task1 = DataX( name="task_datax", datasource_name="first_mysql", datatarget_name="second_mysql", sql="select id, name, code, description from source_table", target_table="target_table", ) # You can custom json_template of datax to sync data. This task create a new # datax job same as task1, transfer record from `first_mysql` to `second_mysql` # We should format the custom json config if we want to format it in web UI task2 = CustomDataX( name="task_custom_datax", json=json.dumps(JSON_TEMPLATE, indent=4) ) # [start resource_limit] resource_limit = DataX( name="resource_limit", datasource_name="first_mysql", datatarget_name="second_mysql", sql="select id, name, code, description from source_table", target_table="target_table", cpu_quota=1, memory_max=100, ) # [end resource_limit] workflow.run() Resource Limit ExampleWe can add resource limit like CPU quota and max memory by passing parameters when declaring tasks. resource_limit = DataX( name="resource_limit", datasource_name="first_mysql", datatarget_name="second_mysql", sql="select id, name, code, description from source_table", target_table="target_table", cpu_quota=1, memory_max=100, ) Dive IntoTask datax.
YAML file example# Define the workflow workflow: name: "DataX" # Define the tasks within the workflow tasks: - name: task task_type: DataX datasource_name: db datatarget_name: db sql: show tables; target_table: table_test - name: task_custon_config task_type: CustomDataX json: $FILE{"example_datax.json"} example_datax.json: { "job": { "content": [ { "reader": { "name": "mysqlreader", "parameter": { "username": "usr", "password": "pwd", "column": [ "id", "name", "code", "description" ], "splitPk": "id", "connection": [ { "table": [ "source_table" ], "jdbcUrl": [ "jdbc:mysql://127.0.0.1:3306/source_db" ] } ] } }, "writer": { "name": "mysqlwriter", "parameter": { "writeMode": "insert", "username": "usr", "password": "pwd", "column": [ "id", "name" ], "connection": [ { "jdbcUrl": "jdbc:mysql://127.0.0.1:3306/target_db", "table": [ "target_table" ] } ] } } } ], "setting": { "errorLimit": { "percentage": 0, "record": 0 }, "speed": { "channel": 1, "record": 1000 } } } } |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |