dataX动态传参数

dataX的json文件:

{
    "job": {
        "content": [
            {
                "reader": {
                    "name": "hdfsreader", 
                    "parameter": {
                        "column": [
                               {
                                "index": 0,
                                "type": "string"
                               },
                               {
                                "index": 1,
                                "type": "string"
                               },
                               {
                                "index": 2,
                                "type": "string"
                               },
                               {
                                "index": 3,
                                "type": "string"
                               },
                               {
                                "type": "string",
                                "value": "$DT"
                               },
                               {
                                "type": "string",
                                "value": "$DN"
                               }
                        ], 
                        "defaultFS": "hdfs://hadoop102:9000", 
                        "encoding": "UTF-8", 
                        "fieldDelimiter": "\t", 
                        "fileType": "text", 
                        "path": "/user/hive/warehouse/ads.db/ccccc/dt=${DT}/dn=$DN"
                    }
                }, 
                "writer": {
                    "name": "mysqlwriter", 
                    "parameter": {
                        "column": ["*"], 
                        "connection": [
                            {
                                "jdbcUrl": "jdbc:mysql://hadoop102:3306/datax", 
                                "table": ["cccc"]
                            }
                        ], 
                        "password": "123456", 
                        "username": "root", 
                        "writeMode": "insert"
                    }
                }
            }
        ], 
        "setting": {
            "speed": {
                "channel": "1"
            }
        }
    }
}

 

选择${参数值}来进行传参 相应的在执行命令上 使用-p “ -D参数值” 进行传参

python /opt/module/datax/bin/datax.py -p "-DDT=${DT} -DDN=${DN}" \
/opt/module/datax/job/datawarehouse/xxxx.json

 


版权声明:本文为qq_37312857原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。