Files
OptiTrainer/server/quoteDBs/fillBigDB_update.sh

35 lines
965 B
Bash
Raw Permalink Normal View History

2020-03-08 20:52:48 -05:00
#!/bin/bash
delete=0
while getopts "d" opt; do
case "$opt" in
d) delete=1
;;
esac
done
2020-10-14 15:42:10 -05:00
find . -maxdepth 1 -name 'quoteStore_202*.sqlite3.gz' | sort | while read db; do
2020-03-08 21:00:53 -05:00
echo unpacking $db
gzip -dc $db >/tmp/xx.sqlite3
echo processing...
sqlite3 /tmp/xx.sqlite3 "create table tmp as select timestamp,replace(replace(symbol,'$',''),'.X','') symbol,data from OptionQuotes;"
sqlite3 /tmp/xx.sqlite3 'drop table OptionQuotes;'
sqlite3 /tmp/xx.sqlite3 'alter table tmp rename to OptionQuotes;'
2020-03-08 21:00:53 -05:00
sqlite3 /tmp/xx.sqlite3 '.dump OptionQuotes' | sqlite3 consolidated.sqlite3
echo filling symbols table
sqlite3 consolidated.sqlite3 'insert INTO Symbols select DISTINCT Symbol from OptionQuotes where OptionQuotes.Symbol not in (select Symbol from Symbols);'
2020-03-08 21:00:53 -05:00
rm /tmp/xx.sqlite3
if [[ "$delete" == "1" ]]; then
echo deleting...
rm $db
else
echo moving to processed folder...
mkdir -p processedDBs
mv $db processedDBs
fi
2020-03-08 20:52:48 -05:00
done