Importing JSON into Mysql(将 JSON 导入 Mysql)
问题描述
我面临的问题是将 JSON 导入 Mysql.我搜索了互联网,搜索了 stackoverflow 和可能更多的来源,但找不到一个正确的解决方案.在这里完全公开 - 我不是 PHP、SQL 也不是 JSON 专家.
the problem that I am facing is importing JSON into Mysql. I have searched the interwebs, I have searched stackoverflow and probably even more sources, but could not find a single proper solution. Full disclosure here - I am not a PHP, SQL nor am I a JSON professional.
我想要完成的事情相当简单:导入这个 JSON 文件 https://developers.facebook.com/tools/explorer/method=GET&path=245226895508982%2Ffeed%3Faccess_token%3D%3Caccess_token%3E=进入Mysql数据库.我知道我需要以某种方式将 JSON 数据分配到列中,然后根据内容相应地管理行.我不需要所有数据,但需要大部分数据.稍后应通过用户的搜索查询回显数据.
What I am trying to accomplish is fairly simple: Import this JSON file https://developers.facebook.com/tools/explorer/method=GET&path=245226895508982%2Ffeed%3Faccess_token%3D%3Caccess_token%3E= into a Mysql database. I understand that I need so somehow allocate the JSON data into columns and then curate the rows accordingly with the content. I do not need all of the data, but most of it. The data should later be echoed through a search query from a user.
我的问题似乎很简单 - 我该怎么做?
My question is seems fairly simple - how can I do it?
P.S:我尝试将其转换为 XML,但我没有足够的权限将 XML 导入 SQL 数据库.转换器也不是最好的工作.
P.S: I tried converting it into XML, but I do not have the sufficient rights to import the XML into the SQL database. Also the converter did not the best job.
推荐答案
您可以将 json 导出到 csv :http://www.danmandle.com/blog/json-to-csv-conversion-utility/ 或 https://github.com/danmandle/JSON2CSV
You can export your json to csv : http://www.danmandle.com/blog/json-to-csv-conversion-utility/ or https://github.com/danmandle/JSON2CSV
然后:
LOAD DATA INFILE 'filepath/your_csv_file.csv' INTO TABLE tablename;
一次性应该没问题.
有关加载数据文件的更多信息.
这篇关于将 JSON 导入 Mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将 JSON 导入 Mysql
基础教程推荐
- 如何在 Laravel 中使用 React Router? 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何替换eregi() 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
