I want to batch import multiple *.CSV files to a SQLite3 database using a batch command line.
I have a batch file(loader.bat) which calls loader.sql to import the csv file into test.db (using sqlite3.exe).
sqlite3.exe test.db ".read loader.sql"
loader.sql is a sqlite script that imports data.csv into a table (tb_data)
.import data.csv tb_data
This works for importing a single file (data.csv). I want to import all the *.csv files (eg data123.csv, data456.csv, data789.csv) in a folder into the same table(tb_data).
I am thinking of using a for loop in the batch script to iterate through the files.
for %%a in (*.csv) do (
echo %%a
sqlite3.exe test.db ".read loader.sql"
)
How do I pass the parameters from the batch script to the sqlite script(loader.sql)?
Aucun commentaire:
Enregistrer un commentaire