OracleReader 插件官方详细说明
https://github.com/alibaba/DataX/blob/master/oraclereader/doc/oraclereader.md
mysqlwriter 插件官方详细说明
https://github.com/alibaba/DataX/blob/master/mysqlwriter/doc/mysqlwriter.md
代码示例,编写文件 oracle_mysql.json
{
"job": {
"content": [
{
"reader": {
"name": "oraclereader",
"parameter": {
"connection": [
{
"jdbcUrl": ["jdbc:oracle:thin:@18.18.40.266:1521:PRD"],
"querySql": ["SELECT aa.BWKEY,aa.MATNR,aa.BDATJ , aa.POPER, aa.actual_unit_cost FROM(SELECT CKMLHD.BWKEY,CKMLHD.MATNR,CKMLCR.BDATJ,CKMLCR.POPER,CKMLCR.PVPRS/CKMLCR.PEINH AS actual_unit_cost FROM SAPSR3.CKMLHD JOIN SAPSR3.CKMLCR ON CKMLCR.KALNR=CKMLHD.KALNR AND CKMLCR.MANDT=CKMLHD.MANDT WHERE CKMLCR.PVPRS > 0 AND CKMLHD.BWKEY IN('5100','9100') AND CONCAT(CKMLCR.BDATJ,SUBSTR(CKMLCR.POPER,2)) <> to_char(SYSDATE,'YYYYMM')) aa"]
}
],
"password": "54645645",
"username": "root",
"where": ""
}
},
"writer": {
"name": "mysqlwriter",
"parameter": {
"column": [
"*"
],
"connection": [
{
"jdbcUrl": "jdbc:mysql://18.18.4.2:3306/linshi_1",
"table": ["company_cost"]
}
],
"username": "root",
"password": "4565406",
"preSql":["truncate table company_cost"],
"writeMode": "insert"
}
}
}
],
"setting": {
"speed": {
"channel": "5"
}
}
}
}
进入datax目录,运行datax命令,开始执行
python bin/datax.py job/oracle_mysql.json