Ashwin
Ashwin

Reputation: 11

Convert large JSON file to MySQL

I have a ~1MB JSON file that needs to be converted to MySQL. The file has close to 400 records. What is the best way to do this using PHP ?

If i try to add 400 records in a single pass, I either get the memory or execution time error. Whats the best way around this ?

Upvotes: 1

Views: 536

Answers (1)

Kalium
Kalium

Reputation: 4682

Try a multi-stage approach. Use json_decode() to turn the records into INSERT statements. Then you can use the FILE command in the mysql client to run all the inserts.

Upvotes: 1

Related Questions