Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

sqlite field separator for importing

Tags:

bash

sqlite

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?

like image 696
Tamil Avatar asked May 26 '26 16:05

Tamil


1 Answers

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

echo -e '.separator "@"\n.import output log_dump' | sqlite log.db
like image 175
kev Avatar answered May 28 '26 09:05

kev



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!