問題描述
我面臨的問題是將 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的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!