foodgod
大路朝天我走中间
2016-03-30 06:28

datax转换mongodb的数据到mysql遇到一个问题

  • 数据
  • mysql
  • mongodb

公司新项目需要从旧的mongodb库了把数据导入到新的mysql库。在用淘宝的datax工具导入数据的时候遇到以下的问题
mongodb的是数据很多都是一个document里不是所有字段都的值都有.
例如:user = [{“name”:”张三”,”id”:”0000001″},
{“age”:12,”id”:”0000002″},
{“name”:”王二麻子”,”age”:13,”id”:”0000003″}]

这样在datax调度Job的时候回报读入和写入的字段数量不同。

请问该如何解决?
我的job.json配置如下:
{
"job": {
"setting": {
"speed": {
"channel": 2
}
},
"content": [
{
"reader": {
"name": "mongodbreader",
"parameter": {
"address": ["192.168.1.1:27017"],
"userName": "",
"userPassword": "",
"dbName": "test",
"collectionName": "usertest"
"column": [
{
"name": "name",
"type": "string"
},

{
"name": "age",
"type": "int"
},
{
"name": "id",
"type": "string"
}
]
}
},
"writer": {
"name": "mysqlwriter",
"parameter": {
"writeMode": "insert",
"username": "user",
"password": "123456",
"column": [
"id",
"name",
"age"
],
"session": [
"set session sql_mode='ANSI'"
],
"preSql": [
"delete from user"
],
"connection": [
{
"jdbcUrl": "jdbc:mysql://192.168.1.1:3306/datax?useUnicode=true&characterEncoding=utf-8",
"table": [
"user"
]
}
]
}
}
}
]
}
}

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

4条回答

为你推荐

换一换