Tamil
Tamil

Reputation: 5358

sqlite field separator for importing

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?

Upvotes: 3

Views: 5457

Answers (1)

kev
kev

Reputation: 161954

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

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

Upvotes: 5

Related Questions