feat(gtfs): add gtfs/import.sh

This commit is contained in:
dancingCycle 2023-06-29 19:43:25 +02:00
parent 01362f55b2
commit dbc899b599
2 changed files with 30 additions and 0 deletions

28
gtfs/import.sh Normal file
View File

@ -0,0 +1,28 @@
#!/bin/bash
#
echo "Started..."
#Started...
#
# special variable $# is the number of arguments
if [ $# -lt 4 ] ; then
echo 'Call ./<script> <db name> <db user> <db schema> <make file path>'
exit 1
fi
#
DB_NAME="$1"
echo "DB_NAME: $DB_NAME"
DB_USER="$2"
echo "DB_USER: $DB_USER"
DB_SCHEMA="$3"
echo "DB_SCHEMA: ${DB_SCHEMA}"
MAKE_PATH="$4"
echo "MAKE_PATH: ${MAKE_PATH}"
#
psql -h localhost -p 5432 -U $DB_USER -f ./sql/drop-schema.sql -d $DB_NAME -v schema=$DB_SCHEMA
#
make -C $MAKE_PATH -f Makefile HOST=localhost PORT=5432 USER=$DB_USER DB=$DB_NAME SCHEMA=$DB_SCHEMA init
#
make -C $MAKE_PATH -f Makefile HOST=localhost PORT=5432 USER=$DB_USER DB=$DB_NAME SCHEMA=$DB_SCHEMA GTFS=/tmp/gtfs/gtfs.zip-stops_zhv.zip load
#
echo "Done."
#done.

2
gtfs/sql/drop-schema.sql Normal file
View File

@ -0,0 +1,2 @@
-- colon before variable: for a prepared statement using named placeholders, this will be a parameter name of the form :name
DROP SCHEMA IF EXISTS :schema CASCADE;