5

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.

1 Answer 1

4

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.

Sign up to request clarification or add additional context in comments.

1 Comment

Thanks, didn't realize the separator option.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.