Skip to content

Commit

Permalink
fixed database scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
cayetanobv committed Jul 14, 2021
1 parent 5ab456e commit 3a1cc0b
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
30 changes: 15 additions & 15 deletions database/update_countries_2021/update_blocks.sql
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
-- 'Niger',
-- 'Moldova',
-- 'Chad',
-- 'Congo DR')
-- 'Congo R')
-- AND gn.id_name_family=2;
-- --
-- -- Get blocks:
Expand Down Expand Up @@ -162,19 +162,19 @@ BEGIN;
)
);

-- INSERT INTO
-- maplex.block (id_geoentity_block,id_geoentity_child)
-- VALUES (
-- (
-- select gn.id_geoentity as id_geoentity_xbap from maplex.geoentity_name gn
-- INNER JOIN maplex.name n ON gn.id_name=n.id_name
-- where n.name='Sub-Saharan Africa' and gn.id_name_family=2
-- ),
-- (
-- select gn.id_geoentity as id_geoentity_xbap from maplex.geoentity_name gn
-- INNER JOIN maplex.name n ON gn.id_name=n.id_name
-- where n.name = 'Congo DR' and gn.id_name_family=2
-- )
-- );
INSERT INTO
maplex.block (id_geoentity_block,id_geoentity_child)
VALUES (
(
select gn.id_geoentity as id_geoentity_xbap from maplex.geoentity_name gn
INNER JOIN maplex.name n ON gn.id_name=n.id_name
where n.name='Sub-Saharan Africa' and gn.id_name_family=2
),
(
select gn.id_geoentity as id_geoentity_xbap from maplex.geoentity_name gn
INNER JOIN maplex.name n ON gn.id_name=n.id_name
where n.name = 'Congo' and gn.id_name_family=2
)
);

COMMIT;
8 changes: 8 additions & 0 deletions doc/blueprints_adddata.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ Instructions to follow to add a new year
## Countries at iepg_data_redux.master_country.
Check that all the countries who come from the input of the data engine (XLSX) are at the table iepg_data_redux.master_country. The mapping field between the xlsx and this table is xlsx_column_name. If an error happens, flux throws an exception.

You could check country names in this way:

```
select xlsx_column_name, iso_3166_1_2_code
from iepg_data_redux.master_country
where xlsx_column_name ilike '%congo%';
```

You can get new countries (or differences in names) in new year with Pandas. Example:

```Python
Expand Down

0 comments on commit 3a1cc0b

Please sign in to comment.