【发布时间】:2022-01-25 17:31:55
【问题描述】:
我正在尝试将文件导入 mariadb (mysql) 数据库。此位置的 Web 上的概念证明文件为 .json 格式。 https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_week.geojson
我知道如何在 db2 for i 上执行此操作。
select * from JSON_TABLE(
SYSTOOLS.HTTPGETCLOB('https://earthquake.usgs.gov' ||
'/earthquakes/feed/v1.0/summary/all_week.geojson',null),
'$.features[*]'
COLUMNS( MILLISEC BIGINT PATH '$.properties.time',
MAG DOUBLE PATH '$.properties.mag',
PLACE VARCHAR(100) PATH '$.properties.place'
)) AS X;
这会从网上读取 a 并列出 3 个字段。用插入子句包围它会将它放入数据库文件中。
我想使用 mariadb 在我的家庭服务器上做同样的事情。最终,脚本将在托管服务器上无人看管地运行。
地震数据的 .json 片段如下所示:
… "features":[
{"type":"Feature",
"properties":{
"mag":1.1,
"place":"58 km WNW of Anchor Point, Alaska",
"time":1640472257402,
"updated":1640472615410,
"tz":null,
"url":"https://earthquake.usgs.gov/earthquakes/eventpage/ak021gi3al5x",
"detail":"https://earthquake.usgs.gov/earthquakes/feed/v1.0/detail/ak021gi3al5x.geojson",
"felt":null,
"cdi":null,
"mmi":null,
"alert":null,
"status":"automatic",
"tsunami":0,
"sig":19,
"net":"ak",
"code":"021gi3al5x",
"ids":",ak021gi3al5x,",
"sources":",ak,",
"types":",origin,",
"nst":null,
"dmin":null,
"rms":0.79,
"gap":null,
"magType":"ml",
"type":"earthquake",
"title":"M 1.1 - 58 km WNW of Anchor Point, Alaska"},
"geometry":{
"type":"Point",
"coordinates":[-152.8406,59.9119,89.7]
},
"id":"ak021gi3al5x"
}, ...
【问题讨论】:
-
展示你的努力,而不是要求一个现成的解决方案。显示您需要帮助的特定错误以及您期望的示例输出。就是说网上有很多新手教程,请问大家有没有研究过?
-
一个有趣的问题。您只是想存储时间、磁力和地点还是整个数据集?你打算用什么来获取数据并存储它?在服务器上运行的前端、bash 脚本等。似乎您甚至可以编写一个通过 CURL 获取数据的脚本。
-
谢谢你,@Ron。相信我,我查看了 mariadb 和 mysql 教程和指南,并没有发现任何关于导入然后解析外部 .json 数据的主题。这就是我求助于这里的原因。