fysloc
fysloc

Reputation: 89

Calling multiple commands in SQLite3 from Command Prompt

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.

Upvotes: 5

Views: 3286

Answers (1)

CL.
CL.

Reputation: 180010

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.

Upvotes: 4

Related Questions