]> git.nbdom.net Git - nb.git/commitdiff
lib/postgres/geo.sql
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Sat, 6 Jan 2018 00:14:46 +0000 (00:14 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Sat, 6 Jan 2018 00:14:46 +0000 (00:14 +0000)
lib/postgres/continent.sql
lib/postgres/zipcode

index 2247e2d1cf3adc0f4d9b1b817bb20077410a87d1..67ad4b6a8cd577b55edc885a5fbf5638da5cde0b 100644 (file)
@@ -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;
index 45be7edd0ff6609242cf5572a0314d84b532e123..2982f4ee8b39c0736664eb036ec1d30e591cc865 100755 (executable)
@@ -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;