my-cmd - MySQL interactive and batch query command-line tool »

Download my-cmd Free Trial »

Load MySQL data from JSON file in command line (Windows / Linux / MacOS)

Import MySQL data from JSON Lines (JSONL)

JSON Lines text format, also called newline-delimited JSON (NDJSON), or Line-delimited JSON (LDJSON). JSON Lines files may be saved with the file extension .jsonl, *.ndjson, *.ldjson.

MongoDB's mongoexport can export collections in JSON Lines format.

parameters:

schema: schema name, use this parameter to load specific schema's data, if not set, use logon user's default schema

table: table name

datafile: data file name

filetype: json|jsonl|ndjson|ldjson

loadtype: append|replace|update|upsert
	append: appends the new rows to the table.
	replace: all rows in the table are deleted and the new data is loaded.
	update: update the rows by the new data.
	upsert upsert the rows by the new data.

updatekey: key feild to update/upsert with, usually use primary key.

nullif: specifies that the column should be loaded as NULL 
("BLANKS" for zero length strings being loaded into numeric columns)

badfile: write the content that can not load to this badfile

errors:  maxinum error count

quit = y|n (quit my-cmd after run in batch mode)


example

In interactive mode:

my-cmd> load table=media_messages 
      > datafile=f:\media_messages.json 
      > filetype=json;



In batch mode:
	 
my-cmd dsn="pan:withdata@192.168.0.102:3306/test" task=load table=media_messages datafile=f:\media_messages.json filetype=json quit=y