Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
FACT Demographic Statistics
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Container Registry
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
FACT
FACT Data Services
FACT Demographic Statistics
Commits
32aab36d
Commit
32aab36d
authored
2 months ago
by
Riccardo Boero
Browse files
Options
Downloads
Patches
Plain Diff
modify tables to take advantage of state-country information
parent
c2c6761f
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
gen_pop_data.sh
+3
-0
3 additions, 0 deletions
gen_pop_data.sh
inputs/modify_tables.sh
+9
-0
9 additions, 0 deletions
inputs/modify_tables.sh
inputs/sql/modify_tables_for_state_country.sql
+24
-0
24 additions, 0 deletions
inputs/sql/modify_tables_for_state_country.sql
with
36 additions
and
0 deletions
gen_pop_data.sh
+
3
−
0
View file @
32aab36d
...
@@ -46,5 +46,8 @@ fi
...
@@ -46,5 +46,8 @@ fi
# load NUTS objects into DB
# load NUTS objects into DB
./inputs/load_table_data.sh
"
$HOST
"
"
$USER
"
"
$PASSWORD
"
./inputs/load_table_data.sh
"
$HOST
"
"
$USER
"
"
$PASSWORD
"
# modify tables to include states and countries data and to be indexed on them
./inputs/modify_tables.sh
"
$HOST
"
"
$USER
"
"
$PASSWORD
"
# dump data and drop database on 'local' instance
# dump data and drop database on 'local' instance
./inputs/dump_and_drop.sh
"
$HOST
"
"
$USER
"
"
$PASSWORD
"
./inputs/dump_and_drop.sh
"
$HOST
"
"
$USER
"
"
$PASSWORD
"
This diff is collapsed.
Click to expand it.
inputs/modify_tables.sh
0 → 100755
+
9
−
0
View file @
32aab36d
#!/bin/bash
# Assign parameters to variables
HOST
=
$1
USER
=
$2
PASSWORD
=
$3
echo
"*** Fix tables to include states and countries data and to be indexed on them:"
mariadb
-h
"
$HOST
"
-u
"
$USER
"
-p
"
$PASSWORD
"
< inputs/sql/modify_tables_for_state_country.sql
This diff is collapsed.
Click to expand it.
inputs/sql/modify_tables_for_state_country.sql
0 → 100644
+
24
−
0
View file @
32aab36d
-- US data
ALTER
TABLE
us_block_2020
ADD
INDEX
idx_fips_state
(
state
);
-- EU data
-- Step 1: Add the country column to the table
ALTER
TABLE
eu_lau
ADD
COLUMN
eu_country
CHAR
(
2
);
-- Step 2: Add the new column to the table index
ALTER
TABLE
eu_lau
ADD
INDEX
idx_eu_country
(
eu_country
);
-- Step 3: Update the country column based on the cntr_code column
UPDATE
eu_lau
SET
eu_country
=
CNTR_CODE
;
-- Step 1: Add the country column to the table
ALTER
TABLE
eu_nuts
ADD
COLUMN
eu_country
CHAR
(
2
);
-- Step 2: Add the new column to the table index
ALTER
TABLE
eu_nuts
ADD
INDEX
idx_eu_country
(
eu_country
);
-- Step 3: Update the country column based on the Country column
UPDATE
eu_nuts
SET
eu_country
=
LEFT
(
GeoID
,
2
);
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment