31 lines
612 B
Bash
Executable File
31 lines
612 B
Bash
Executable File
#!/usr/bin/env bash
|
|
set -eau -o pipefail
|
|
|
|
if [ "$#" -ne 1 ]; then
|
|
echo "Usage: gen-fantoir.sh path-to-fantoir-data"
|
|
echo ""
|
|
echo "ERROR: Missing fantoir data"
|
|
exit 1
|
|
fi
|
|
|
|
# Setup TMP dirs
|
|
tmpDir=$(mktemp -d)
|
|
clean_tmp () {
|
|
rm -r "${tmpDir}"
|
|
}
|
|
trap clean_tmp EXIT
|
|
tmpCsv="${tmpDir}"/fantoir.csv
|
|
tmpSql="${tmpDir}"/import-fantoir.sql
|
|
|
|
echo "Generating fantoir CSV"
|
|
cargo run --release -- "$1" > "${tmpCsv}"
|
|
|
|
echo "Generating fantoir SQLite DB"
|
|
cat >"${tmpSql}" <<EOF
|
|
.separator ";"
|
|
.import ${tmpCsv} fantoir
|
|
EOF
|
|
sqlite3 fantoir.sqlite < "${tmpSql}"
|
|
|
|
echo "DB generated at $(pwd)/fantoir.sqlite"
|