]> git.nbdom.net Git - nb.git/commitdiff
lib/postgres/continent.sql
authorNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 5 Jan 2018 23:32:16 +0000 (23:32 +0000)
committerNicolas Boisselier <nicolas.boisselier@gmail.com>
Fri, 5 Jan 2018 23:32:16 +0000 (23:32 +0000)
lib/postgres/continent.sql
lib/postgres/zipcode.sql

index a296fabd2ae84ad714e0f2ecf3a3b2598f52c21e..f00a541f84bac9211b93682deda8bd361f272326 100644 (file)
@@ -1,18 +1,20 @@
 DROP TABLE IF EXISTS continent;
 CREATE TABLE IF NOT EXISTS continent (
   id char(3) PRIMARY KEY,
-  name varchar(200)
+  name varchar(200),
+  geoid bigint
 );
 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;
-INSERT INTO continent VALUES ('AF','Africa');
-INSERT INTO continent VALUES ('AS','Asia');
-INSERT INTO continent VALUES ('EU','Europe');
-INSERT INTO continent VALUES ('NA','North America');
-INSERT INTO continent VALUES ('OC','Oceania');
-INSERT INTO continent VALUES ('SA','South America');
-INSERT INTO continent VALUES ('AN','Antarctica');
+-- 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/"' WITH (format 'text', NULL '');
 COMMIT;
index 0cdf76170e85a80f9243e56e894378ccd6860a40..3dec4592b9c5fcb4c705b0d99a3d341ae8f8bb71 100644 (file)
@@ -24,7 +24,5 @@ GRANT ALL ON TABLE zipcode TO root;
 
 BEGIN TRANSACTION;
 DELETE FROM zipcode;
--- COPY zipcode FROM stdin WITH (format 'text');
 COPY zipcode FROM PROGRAM 'curl -s http://download.geonames.org/export/zip/allCountries.zip | zcat | sed "s,\\\\,\\\\\\\\,g"' WITH (format 'text', NULL '');
--- COPY geo FROM PROGRAM '/opt/nb/lib/postgres/zipcode' WITH (format 'text', NULL '');
 COMMIT;