etl - 如何使用 talend 将 API 数据加载到 MYSQL 数据库中
问题描述
我是 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
}
解决方案
这取决于您要从 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|
'---+----+-------------------+-------------------'
推荐阅读
- r - R:除了一个单元格之外有唯一的行,如何获得保持差异的唯一行
- android - 在android中的viewmodel中扭曲MVP演示者?
- postgresql - 更改 solr 存储日期和时间的方式
- c# - 在 asyc 方法中抛出新异常
- google-chrome-extension - Chrome 扩展开发试图使字体加粗
- c++ - 警告 C26454:算术溢出:“-”操作在编译时产生负的无符号结果 (io.5)
- sql-server - 带有过滤器的 SQL Server 分组依据
- javascript - 如何从 JSON.stringify 中正确提取数据
- python - 将列中所有时间条目的时间格式从小时更改为上午/下午
- c# - C# GetWindowModuleFileName 和 GetWindowText 给出不同句柄的结果