【问题标题】:How to load API data into MYSQL database using talend如何使用 talend 将 API 数据加载到 MYSQL 数据库中
【发布时间】:2020-07-14 07:12:52
【问题描述】:

我是 Talend 的新手。我想将我的 api(例如:www.abc.com/villages/)数据加载到我的 mysql 数据库中。我该怎么做?

这是我的 api 数据:

{
    "message": "Resource created/Updated",
    "data": {
        "items": [
            {
                "id": 256,
                "name": "Abc",
                "createdAt": "2020-07-09 04:06:23",
                "updatedAt": "2020-07-09 04:06:23"
            },
            {
                "id": 512,
                "name": "Xyz",
                "createdAt": "2020-07-09 04:06:23",
                "updatedAt": "2020-07-09 04:06:23"
            }
        ],
        "page": 1,
        "total": 51551,            
    },
    "type": null
}

【问题讨论】:

    标签: etl talend


    【解决方案1】:

    这取决于您要从 json 中提取哪些数据并加载到 MySQL 表中。
    首先,您需要使用 tExtractJSONFields 组件扁平化您的 json 数据:

    这里我提取 id、name、createAt 和 updateAt;并将此数据记录到控制台。您可以将 tLogRow 替换为 db 输出组件。

    .---+----+-------------------+-------------------.
    |                   tLogRow_1                    |
    |=--+----+-------------------+------------------=|
    |id |name|createdAt          |updatedAt          |
    |=--+----+-------------------+------------------=|
    |256|Abc |2020-07-09 04:06:23|2020-07-09 04:06:23|
    |512|Xyz |2020-07-09 04:06:23|2020-07-09 04:06:23|
    '---+----+-------------------+-------------------'
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2023-03-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-04-08
      相关资源
      最近更新 更多