MySQL Forums
Forum List  »  MySQL Shell

How to execute util.importTable command several times in MySQL Shell using a variable?
Posted by: JOAO SILVA
Date: March 10, 2020 09:11PM

The below code is used in MySQL Sehll JavaScript to fill a MySQL table with the data from a csv file.

MySQL localhost JS >util.importTable("D:/Column_1.csv", {schema: "data", table: "table_1", columns: ["column"], dialect: "csv-unix", skipRows: 0, showProgress: true, threads: 8})

Now I need to execute this command several times, as I need to fill table_1, table_2, table_3, ... , table_15 with the respective csv file (file_1.csv, file_2.csv, file_3.csv, ... , file_15.csv).

So, I would like to ask your help to write a code to run in MySQL Shell JavaScript. Something like:

MySQL localhost JS >For (int i = 1, i <= 15; i++) {executeQuery("util.importTable("D:/Column_" + i + ".csv", {schema: "data", table: "table_" + i + "", columns: ["column"], dialect: "csv-unix", skipRows: 0, showProgress: true, threads: 8})")}

Thanks

Options: ReplyQuote


Subject
Views
Written By
Posted
How to execute util.importTable command several times in MySQL Shell using a variable?
367
March 10, 2020 09:11PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.