第三周学习记录
对DataX进行了应用,将多个表数据同步到了一张数据库表中。
DataX在安装时需要注意python版本的影响。
如果是python需要替换一下文件:

实现:
通过编写json文件,实现利用DataX同步三个表数据到一个数据表里。

分别执行三个文件,在json文件中指定数据与列的对应关系,如下所示:
{
"job": {
"setting": {
"speed": {
"channel": 2
}
},
"content": [
{
"reader": {
"name": "txtfilereader",
"parameter": {
"path": ["C:/study/datax/job/hb.txt"],
"encoding": "UTF-8",
"column": [
{
"index": 0,
"type": "string"
},
{
"index": 1,
"type": "string"
}
{
"index": 2,
"type": "string"
}
{
"index": 3,
"type": "string"
}
{
"index": 4,
"type": "string"
}
{
"index": 5,
"type": "string"
}
{
"index": 6,
"type": "string"
}
{
"index": 7,
"type": "string"
}
{
"index": 8,
"type": "string"
}
{
"index": 9,
"type": "string"
}
],
"fieldDelimiter": " ",
"skipHeader": "TRUE"
}
},
"writer": {
"name": "mysqlwriter",
"parameter": {
"writeMode": "insert",
"username": "root",
"password": "ms911",
"column": [
"id"
"product_name"
"industry"
"year"
"registration"
"company"
"source"
"people"
"evaluate"
"introduction"
],
"session": [],
"connection": [
{
"jdbcUrl": "jdbc:mysql://127.0.0.1:3306/datax_test?useUnicode=true&characterEncoding=utf8&useSSL=false&serverTimezone=GMT%2B8",
"table": ["technology"]
}
]
}
}
}
]
}
}
在控制台执行:
python datax.py路径 json文件路径
即可。
浙公网安备 33010602011771号