Revision 11450
Added by Paul Sarando about 11 years ago
derived/biengeo/load-geoscrub-input.sh | ||
---|---|---|
19 | 19 |
# Note, to force data to download from DATA_URL, ensure the DATAFILE is deleted |
20 | 20 |
# before running this script. |
21 | 21 |
|
22 |
DB_USER="bien" |
|
23 |
DB_HOST="vegbiendev" |
|
22 | 24 |
SCRIPT_DIR=$(dirname $0) |
23 | 25 |
DATA_URL="http://fs.vegpath.org/exports/geoscrub_input.no_header.cols=country,stateProvince,county,decimalLatitude,decimalLongitude.csv" |
24 | 26 |
DATADIR="${SCRIPT_DIR}/input" |
... | ... | |
47 | 49 |
echo "Loading vegbien data from ${DATAFILE}" |
48 | 50 |
|
49 | 51 |
# clear previous data |
50 |
psql -e -d geoscrub --set ON_ERROR_STOP=1 < "${SCRIPT_DIR}/truncate.vegbien_geoscrub.sql" |
|
52 |
psql -e -U "$DB_USER" -h "$DB_HOST" -d geoscrub --set ON_ERROR_STOP=1 < "${SCRIPT_DIR}/truncate.vegbien_geoscrub.sql"
|
|
51 | 53 |
if [[ $? != 0 ]]; then |
52 | 54 |
echo "Could not clear data from vegbien_geoscrub tables." |
53 | 55 |
exit 1 |
54 | 56 |
fi |
55 | 57 |
|
56 | 58 |
# load |
57 |
psql -c "COPY vegbien_geoscrub FROM '${DATAFILE}' WITH CSV" geoscrub
|
|
59 |
psql -U "$DB_USER" -h "$DB_HOST" -c "\COPY vegbien_geoscrub FROM '${DATAFILE}' WITH CSV" geoscrub
|
|
58 | 60 |
|
Also available in: Unified diff
Added db user and host to load-geoscrub-input.sh
The psql commands in load-geoscrub-input.sh will now connect with a
specific user on a specific host.
Updated the 'COPY' sql statement to a '\COPY' statement, so that the
psql user does not have to be a PostgreSQL superuser.