From 7bffa445025314ff930722942b79ab3297fdaed7 Mon Sep 17 00:00:00 2001 From: Ed Chalstrey Date: Mon, 28 Mar 2022 14:42:29 +0100 Subject: [PATCH] use env vars properly? --- etl/load_geometries.sh | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/etl/load_geometries.sh b/etl/load_geometries.sh index a2b20416..27d6b07f 100755 --- a/etl/load_geometries.sh +++ b/etl/load_geometries.sh @@ -1,11 +1,5 @@ #!/usr/bin/env bash -# Gather stored postgres variables -export PGHOST=${PGHOST} -export PGDATABASE=${PGDATABASE} -export PGUSER=${PGUSER} -export PGPASSWORD=${PGPASSWORD} - # # Load geometries from GeoJSON to Postgres # - assume postgres connection details are set in the environment using PGUSER, PGHOST etc. @@ -23,12 +17,12 @@ mastermap_dir=$1 find $mastermap_dir -type f -name '*.3857.csv' \ -printf "$mastermap_dir/%f\n" | \ parallel \ -cat {} '|' psql -c "\"COPY geometries ( geometry_geom, source_id ) FROM stdin WITH CSV HEADER;\"" +cat {} '|' PGHOST=$PGHOST PGDATABASE=$PGDATABASE PGUSER=$PGUSER PGPASSWORD=$PGPASSWORD psql -c "\"COPY geometries ( geometry_geom, source_id ) FROM stdin WITH CSV HEADER;\"" # # Delete any duplicated geometries (by TOID) # -psql -c "DELETE FROM geometries a USING ( +PGHOST=$PGHOST PGDATABASE=$PGDATABASE PGUSER=$PGUSER PGPASSWORD=$PGPASSWORD psql -c "DELETE FROM geometries a USING ( SELECT MIN(ctid) as ctid, source_id FROM geometries GROUP BY source_id