2025-11-11 06:33:53 +01:00

28 lines
927 B
Bash
Executable File

#!/bin/bash
# Define the name of the SQLite commands file
Imp_SQL_FILE="import_json.sql" # sql file perform the raw import
Ext_SQL_FILE="extract.sql" # sql file to extract the data from the imported db
# Database file names:
IMP_DB_FILE="import.db"
TGT_DB_FILE="food.db"
MEMORY_DB_FILE="memory.db"
# cleanup from previous runs
[ -e $IMP_DB_FILE ] && echo "$(date +"%T")|deleting $IMP_DB_FILE file" && rm $IMP_DB_FILE
[ -e $TGT_DB_FILE ] && echo "$(date +"%T")|deleting $TGT_DB_FILE file"&& rm $TGT_DB_FILE
[ -e $MEMORY_DB_FILE ] && echo "$(date +"%T")|deleting $TGT_DB_FILE file"&& rm $MEMORY_DB_FILE
# Execute SQLite commands from the SQL file
echo "$(date +"%T")|importing json file started"
sqlite3 "$IMP_DB_FILE" < "$Imp_SQL_FILE" 2>/dev/null
echo "$(date +"%T")|importing json file finished"
# Execute SQLite commands from the SQL file
sqlite3 < "$Ext_SQL_FILE"
echo "$(date +"%T")|creating $TGT_DB_FILE finished"