From: Nicolas Boisselier Date: Sat, 6 Jan 2018 00:14:46 +0000 (+0000) Subject: lib/postgres/geo.sql X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=0252ec0448a80c160e7d95d7afe04e86be27809c;p=nb.git lib/postgres/geo.sql --- diff --git a/lib/postgres/continent.sql b/lib/postgres/continent.sql index 2247e2d1..67ad4b6a 100644 --- a/lib/postgres/continent.sql +++ b/lib/postgres/continent.sql @@ -1,20 +1,13 @@ DROP TABLE IF EXISTS continent; CREATE TABLE IF NOT EXISTS continent ( - id bigint PRIMARY KEY, - id char(3) UNIQUE, + id char(3) PRIMARY KEY, name varchar(200), + geoid bigint UNIQUE ); GRANT ALL ON TABLE continent TO www; GRANT ALL ON TABLE continent TO nico; GRANT ALL ON TABLE continent TO root; BEGIN TRANSACTION; DELETE FROM continent; --- NB 05.01.18 INSERT INTO continent VALUES ('AF','Africa'); --- NB 05.01.18 INSERT INTO continent VALUES ('AS','Asia'); --- NB 05.01.18 INSERT INTO continent VALUES ('EU','Europe'); --- NB 05.01.18 INSERT INTO continent VALUES ('NA','North America'); --- NB 05.01.18 INSERT INTO continent VALUES ('OC','Oceania'); --- NB 05.01.18 INSERT INTO continent VALUES ('SA','South America'); --- NB 05.01.18 INSERT INTO continent VALUES ('AN','Antarctica'); -COPY continent FROM PROGRAM 'curl -s http://download.geonames.org/export/dump/readme.txt | awk "/^Continent codes/ {ok=1} ok==1 && /^$/{exit} ok==1 {print \$0}" | tail -n +2 | sed -e "s/ : /\t/" -e "s/[\t ]\+geonameId=/\t/" | cut -f 3,1,2' WITH (format 'text', NULL ''); +COPY continent FROM PROGRAM 'curl -s http://download.geonames.org/export/dump/readme.txt | awk "/^Continent codes/ {ok=1} ok==1 && /^$/{exit} ok==1 {print \$0}" | tail -n +2 | sed -e "s/ : /\t/" -e "s/[\t ]\+geonameId=/\t/"' WITH (format 'text', NULL ''); COMMIT; diff --git a/lib/postgres/zipcode b/lib/postgres/zipcode index 45be7edd..2982f4ee 100755 --- a/lib/postgres/zipcode +++ b/lib/postgres/zipcode @@ -1,7 +1,7 @@ #!/usr/bin/env perl use strict; use warnings; -#die('obsolete !!!'); +die('obsolete !!!'); @ARGV = ('curl -s http://download.geonames.org/export/zip/allCountries.zip | zcat |'); #exec($ARGV[0]); exit;