将JSON导入Mysql [英] Importing JSON into Mysql
问题描述
我想要完成的是相当简单的:导入此JSON文件 https://developers.facebook.com/tools/explorer/method=GET&path=245226895508982%2Ffeed%3Faccess_token%3D %3Caccess_token%3E =
到Mysql数据库。
我明白,我需要以某种方式将JSON数据分配到列中,然后根据内容设置相应的行。我不需要所有的数据,但大部分数据。稍后将通过用户的搜索查询回传数据。
我的问题似乎很简单 - 我该怎么办?
PS:我尝试将其转换为XML,但是我没有足够的权限将XML导入SQL数据库。另外转换器并不是最好的工作。
您可以将json导出到csv: http://www.danmandle.com/blog/json-to-csv-conversion-utility/ 或 https://github.com/danmandle/JSON2CSV
然后:
LOAD DATA INFILE'filepath / your_csv_file.csv'INTO TABLE tablename;
对于一张照片应该是可以的。
加载数据infile 的更多信息。
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.
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: 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.
You can export your json to csv : http://www.danmandle.com/blog/json-to-csv-conversion-utility/ or https://github.com/danmandle/JSON2CSV
Then :
LOAD DATA INFILE 'filepath/your_csv_file.csv' INTO TABLE tablename;
It should be okay for a oneshot.
More info for load data infile.
这篇关于将JSON导入Mysql的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!