Thanks to previous SO posts I can now merge sqlite databases.
But I want to run this merging in an automatic way using a bash script,
I have tried various ways and here is my latest and most complete fail:
## DB to merge
I1=d1.db
I2=d2.db
## Command to run
CMD='attach \'d2.db\' as toMerge; BEGIN; insert into sae select * from toMerge.sae; COMMIT; detach toMerge;'
echo $CMD
## Pass to sqlite
sqlite3 $I1 $CMD
Two issues meet here:
1- passing a bash variable (here d2.db). I had tried with the quote function as well:
CMD='attach quote('$I2') as toMerge; BEGIN; insert into sae select * from toMerge.sae; COMMIT; detach toMerge;'
2- the * in the select command that is interpreted in the bash way, hence the single quotes.