Revision 11479
Added by Paul Sarando about 11 years ago
derived/biengeo/load-geoscrub-input.sh | ||
---|---|---|
15 | 15 |
# Jim Regetz |
16 | 16 |
# NCEAS |
17 | 17 |
# Created Nov 2012 |
18 |
# |
|
19 |
# Paul Sarando |
|
20 |
# iPlant Collaborative |
|
21 |
# Updated Oct 2013 |
|
18 | 22 |
|
19 | 23 |
# Note, to force data to download from DATA_URL, ensure the DATAFILE is deleted |
20 | 24 |
# before running this script. |
21 | 25 |
|
26 |
DB_NAME="geoscrub" |
|
22 | 27 |
DB_USER="bien" |
23 |
DB_HOST="vegbiendev"
|
|
28 |
DB_HOST="localhost"
|
|
24 | 29 |
SCRIPT_DIR=$(dirname $0) |
25 | 30 |
DATA_URL="http://fs.vegpath.org/exports/geoscrub_input.no_header.cols=country,stateProvince,county,decimalLatitude,decimalLongitude.csv" |
26 | 31 |
DATADIR="${SCRIPT_DIR}/input" |
... | ... | |
49 | 54 |
echo "Loading vegbien data from ${DATAFILE}" |
50 | 55 |
|
51 | 56 |
# clear previous data |
52 |
psql -e -U "$DB_USER" -h "$DB_HOST" -d geoscrub --set ON_ERROR_STOP=1 < "${SCRIPT_DIR}/truncate.vegbien_geoscrub.sql"
|
|
57 |
psql -e -U "$DB_USER" -h "$DB_HOST" -d "$DB_NAME" --set ON_ERROR_STOP=1 < "${SCRIPT_DIR}/truncate.vegbien_geoscrub.sql"
|
|
53 | 58 |
if [[ $? != 0 ]]; then |
54 | 59 |
echo "Could not clear data from vegbien_geoscrub tables." |
55 | 60 |
exit 1 |
56 | 61 |
fi |
57 | 62 |
|
58 | 63 |
# load |
59 |
psql -U "$DB_USER" -h "$DB_HOST" -c "\COPY vegbien_geoscrub FROM '${DATAFILE}' WITH CSV" geoscrub
|
|
64 |
psql -U "$DB_USER" -h "$DB_HOST" -d "$DB_NAME" -c "\COPY vegbien_geoscrub FROM '${DATAFILE}' WITH CSV"
|
|
60 | 65 |
|
Also available in: Unified diff
Updated load-geoscrub script with configurable db.
load-geoscrub-input.sh now uses a variable with the db name defined at
the top of the script.
Updated the default db host to 'localhost' for this script.