From: Nicolas Boisselier Date: Sat, 6 Jan 2018 05:26:05 +0000 (+0000) Subject: lib/postgres/geofeature.sql X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=afa8498a325dd95e20c746ab640f790f94bfcbe8;p=nb.git lib/postgres/geofeature.sql --- diff --git a/lib/postgres/geo.sql b/lib/postgres/geo.sql index 96100c78..c4f37a09 100644 --- a/lib/postgres/geo.sql +++ b/lib/postgres/geo.sql @@ -39,9 +39,6 @@ CREATE TABLE geo ( timezone varchar(40), updated date ); -GRANT ALL ON ALL TABLES IN SCHEMA public TO www; -GRANT ALL ON ALL TABLES IN SCHEMA public TO nico; -GRANT ALL ON ALL TABLES IN SCHEMA public TO root; CREATE INDEX IF NOT EXISTS geo_country_idx ON geo (country); BEGIN TRANSACTION; DELETE FROM geo; diff --git a/lib/postgres/geofeature.sql b/lib/postgres/geofeature.sql new file mode 100644 index 00000000..dec6c0b3 --- /dev/null +++ b/lib/postgres/geofeature.sql @@ -0,0 +1,11 @@ +DROP TABLE IF EXISTS geofeature; +CREATE TABLE geofeature ( + id varchar(10) PRIMARY KEY, + title varchar(80), + description varchar(500) +); +-- CREATE INDEX IF NOT EXISTS geofeature_country_idx ON geofeature (country); +BEGIN TRANSACTION; +DELETE FROM geofeature; +COPY geofeature FROM PROGRAM 'curl -s http://www.geonames.org/export/codes.html | tr -d "\n" | sed "s/<.tr>/\n/g" | grep "]*> *)/\t/g" -e "s/^.*?=.([A-Z0-9\.]*)[^\t]+\t/\1/" -e "s/\t+/\t/g" | cut -f 1-3 | grep -v "not available"' WITH (format 'text', NULL ''); +COMMIT;