Friday, January 4, 2013

MySQL JSON import / export tools updated

A user of mysqlimport. Josh Baird, reminded me of a feature which I should have added from teh start, but which was forgotten about. The deal is that when you put a bunch of JSON objects in a file, you have a couple of options on how to do this.

The most obvious is maybe to export as a JSON array of objects, like this:
{"id":1, "name": "Geraint Watkins"},
{"id":2, "name": "Kim Wilson"}
But this is not what mysqljsoninport supported and this is not how, say, MongoDB exports JSON by default. The reason is that for large amount if data this is cumbersome, as what is in the file is actually one big JSON object containing all the data. This is difficult to parse, requires that a lot of data is read and that the object in whole is kept in memory, unless some clever processing is done. And if we are clever, this is still not effective. Rather, what was supported by mysqljsonimport and how MongoDB exports to JSON is as multiple objects without separators, i.e. you read an object, processit, and then you read some optional blankspace until you reach another object, like this:

{"id":1, "name": "Geraint Watkins"}
{"id":2, "name": "Kim Wilson"}

The latter is more effective, but often the former is used also. So mysqljsonimport now supports both formats, and mysqlexport can optionally export as a single JSON array of objects in a file.

Download the most recent version from Sourcefore: mysqlimport 1.5 and mysqlexport 1.2



Céd said...

Hi Anders, thx for this useful tool.

Tell me, is it possible to load a json file with this kind of format :


just for loaded key1 and key2 in base ?


Anmona Ami said...

Secured loans can be a abundant way to accession money. But afore you alike anticipate about applying for one, accomplish abiding that you accept the accomplished action and risks associated with them. Payday Loans

jhon said...

Cash advances are an advantage for accepting money online. Added and added bodies are appliance online options in adjustment to accomplish their affairs a smoother operation. Online banknote advances and payday loans are actuality acclimated so generally because of the convenience.
payday loans

jhon said...

This should no agnosticism accord you a blow of abatement and abundance to agenda that you don't consistently acquire to access Uncle Bruce, who makes it a point that the accomplished association gets to apperceive about the so alleged accommodation he avant-garde you, in adjustment to get a loan.
Payday Loans

Shan Jonson said...

Also, thanks to the internet's ability to put people in instant contact with various businesses, it is easier than ever before to obtain payday loans. In fact, the entire application procedure has been lessened to just a couple of hours. Imagine, in a little over two hours, you could have the money you need in hand. This is why obtaining payday loans online has become the new way to obtain the funding needed for your emergency.
payday loans corona