I want to be able to make a batchfile that will loop through every file in a directory and import it inside SQlite3. The problem I have is that SQlite3 does not accept multiple commands from command prompt/batch, only 1 command.
What I have tried is :
for %%f in (./tmp/*.csv) do (
echo %%f
sqlite3 database.db ".separator '|'" ".import './tmp/%%f' Dirs"
)
And I get a too many options error, as it is only expecting a single command, while I need more than 1.
I also cannot write a second text file to be called by sqlite3 as the file being imported will change for every iteration.
Help would be appreciated.
You can use the option -separator
to set the separator (whose default already is |
).
If you'd really need to execute multiple commands, you could write them to a file and .read
that, or echo
all of them and pipe them into sqlite3
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With