将 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;
一次性应该没问题.
有关加载数据文件的更多信息.
相关文章