Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • fact/data/FACT_power
1 result
Show changes
Commits on Source (2)
......@@ -13,11 +13,27 @@ Location, size, and type of electricity generation plants and transmission lines
## Use
1. Pull the image:
> docker pull registry.git.nilu.no/fact/data/fact_power:latest
2. Run this data service:
>docker run -t -i --name fact_power -e MARIADB_DATABASE=FACT_power -e MYSQL_ROOT_PASSWORD=devops -p 3313:3306 -d registry.git.nilu.no/fact/data/fact_power:latest
1. Through the command line:
```bash
docker pull registry.git.nilu.no/fact/data/fact_power:latest
docker run -t -i --name fact_power -e MARIADB_DATABASE=FACT_power -e MYSQL_ROOT_PASSWORD=devops -p 3313:3306 -d registry.git.nilu.no/fact/data/fact_power:latest
```
2. Through a docker-compose file:
```yaml
version: '3.8'
services:
fact_power:
image: registry.git.nilu.no/fact/data/fact_power:latest
container_name: fact_power
environment:
MARIADB_DATABASE: FACT_power
MYSQL_ROOT_PASSWORD: devops
ports:
- "3313:3306"
restart: unless-stopped
```
which could be executed with `docker-compose up fact_power -d`.
The container makes available a MariaDB instance with the full database on population **FACT_power**. It is reachable on port 3313 of the localhost and the root password is 'devops'.
......
......@@ -43,5 +43,8 @@ fi
# load vector data into DB
./inputs/load_vector_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
./inputs/dump_and_drop.sh "$HOST" "$USER" "$PASSWORD"
#!/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
-- US data
-- Step 1: Add the fips_state column to the table
ALTER TABLE us_gen
ADD COLUMN fips_state CHAR(2);
-- Step 2: Add the new column to the table index
ALTER TABLE us_gen
ADD INDEX idx_fips_state (fips_state);
-- Step 3: Update the fips_state column based on the State column
UPDATE us_gen
SET fips_state = CASE state
WHEN 'Alabama' THEN '01'
WHEN 'Alaska' THEN '02'
WHEN 'Arizona' THEN '04'
WHEN 'Arkansas' THEN '05'
WHEN 'California' THEN '06'
WHEN 'Colorado' THEN '08'
WHEN 'Connecticut' THEN '09'
WHEN 'Delaware' THEN '10'
WHEN 'Florida' THEN '12'
WHEN 'Georgia' THEN '13'
WHEN 'Hawaii' THEN '15'
WHEN 'Idaho' THEN '16'
WHEN 'Illinois' THEN '17'
WHEN 'Indiana' THEN '18'
WHEN 'Iowa' THEN '19'
WHEN 'Kansas' THEN '20'
WHEN 'Kentucky' THEN '21'
WHEN 'Louisiana' THEN '22'
WHEN 'Maine' THEN '23'
WHEN 'Maryland' THEN '24'
WHEN 'Massachusetts' THEN '25'
WHEN 'Michigan' THEN '26'
WHEN 'Minnesota' THEN '27'
WHEN 'Mississippi' THEN '28'
WHEN 'Missouri' THEN '29'
WHEN 'Montana' THEN '30'
WHEN 'Nebraska' THEN '31'
WHEN 'Nevada' THEN '32'
WHEN 'New Hampshire' THEN '33'
WHEN 'New Jersey' THEN '34'
WHEN 'New Mexico' THEN '35'
WHEN 'New York' THEN '36'
WHEN 'North Carolina' THEN '37'
WHEN 'North Dakota' THEN '38'
WHEN 'Ohio' THEN '39'
WHEN 'Oklahoma' THEN '40'
WHEN 'Oregon' THEN '41'
WHEN 'Pennsylvania' THEN '42'
WHEN 'Rhode Island' THEN '44'
WHEN 'South Carolina' THEN '45'
WHEN 'South Dakota' THEN '46'
WHEN 'Tennessee' THEN '47'
WHEN 'Texas' THEN '48'
WHEN 'Utah' THEN '49'
WHEN 'Vermont' THEN '50'
WHEN 'Virginia' THEN '51'
WHEN 'Washington' THEN '53'
WHEN 'West Virginia' THEN '54'
WHEN 'Wisconsin' THEN '55'
WHEN 'Wyoming' THEN '56'
WHEN 'District of Columbia' THEN '11'
ELSE NULL
END;
-- EU data
-- Step 1: Add the country column to the table
ALTER TABLE eu_gen
ADD COLUMN eu_country CHAR(2);
-- Step 2: Add the new column to the table index
ALTER TABLE eu_gen
ADD INDEX idx_eu_country (eu_country);
-- Step 3: Update the country column based on the cntr_code column
UPDATE eu_gen
SET eu_country = LEFT(nuts2, 2);