Calling multiple commands in SQLite3 from the command line

I want to be able to make a batch file that will go through each file in a directory and import it inside SQlite3. The problem is that SQlite3 does not accept multiple commands from the command line / package, only 1 command.

I tried:

for %%f in (./tmp/*.csv) do ( echo %%f sqlite3 database.db ".separator '|'" ".import './tmp/%%f' Dirs" ) 

And I get too many parameter errors, since it expects only one command, whereas I need more than 1.

I also cannot write a second text file that sqlite3 will invoke, since the imported file will change for each iteration.

Help will be appreciated.

+4
source share
1 answer

You can use the -separator option to set the delimiter (the default is already | ).

If you really need to execute several commands, you can write them to a file and .read , or all echo , and transfer them to sqlite3 .

+4
source

All Articles