I have the following text line :
"Field1":"Data1","Field2":"Data2","Field3":"Data3","Field4":"Data4" ...
And I need to generate the following INSERT statement :
INSERT INTO data (Field1,Field2,Field3,Field4 ... ) VALUES(Data1,Data2,Data3,Data4 ... );
Any ideas on how to do it in BASH ?
Thanks in advance!
INSERTstatement, you have to convert inputs into type forms that MySQL understands ( see 8 in the list by @CharlesDuffy ). For a "generic" csv->Postgres script, I ended up with flags to denote column types as boolean, dates, strings, and numerics. For example, you might want to treat "0" as a boolean sometimes ( outputtingfalse) or leave it as an integer based on the table column's type. That's not something a script can "magically" know based on the raw inputs.