sqlite field separator for importing

bash, sqlite

Solution

You should pass two commands to sqlite at the same time:

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

Problem

I Just started using SQLite for our log processing system where I just import a file in to sqlite database which has '@' as 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 via a bash script ``` sqlite log.db '.separator "@"' sqlite log.db '.import output log_dump' ``` it doesn't. The separator shifts back to '|' and I'm getting an error saying that there are insufficient columns ``` output line 1: expected 12 columns of data but found 1 ``` How can I overcome this issue?

Original source

Related problems