Sqlite field separator for import

I just started using SQLite for our log processing system, where I simply imported the file into the sqlite database, which has an "@" as a field separator.

If I run the following in SQLite repl

$ sqlite3 log.db 
sqlite> .separator "@"
sqlite> .import output log_dump

It works [import was successful]. But if I try to do the same with a bash script

sqlite log.db '.separator "@"'
sqlite log.db '.import output log_dump'

this is not true. The separator moves back to '|' and I get an error that there are not enough columns

output line 1: expected 12 columns of data but found 1

How can I solve this problem?

+3
source share
1 answer

You must pass two commands to sqlite simultaneously:

echo -e '.separator "@"\n.import output log_dump' | sqlite log.db
+5
source

All Articles