Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
COVID-19-Data-Integration
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Ivy Wang
COVID-19-Data-Integration
Commits
0a282df4
Commit
0a282df4
authored
3 years ago
by
Ivy Wang
Browse files
Options
Downloads
Patches
Plain Diff
change vaccination rate to vaccination number
parent
e6b79fbe
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
data/OverallSchema.sql
+9
-9
9 additions, 9 deletions
data/OverallSchema.sql
initial_data_scripts/init_asia.py
+14
-10
14 additions, 10 deletions
initial_data_scripts/init_asia.py
prototype_db
+0
-0
0 additions, 0 deletions
prototype_db
prototype_main_backend.py
+9
-10
9 additions, 10 deletions
prototype_main_backend.py
with
32 additions
and
29 deletions
data/OverallSchema.sql
+
9
−
9
View file @
0a282df4
...
...
@@ -80,9 +80,9 @@ CREATE TABLE Cases_Per_District(
-- keeps track of vaccinations per Country
CREATE
TABLE
Vaccinations_Per_Country
(
first_vaccination_
rate
FLOA
T
NOT
NULL
,
second_vaccination_
rate
FLOA
T
NOT
NULL
,
third_vaccination_
rate
FLOA
T
NOT
NULL
,
first_vaccination_
number
BIGIN
T
NOT
NULL
,
second_vaccination_
number
BIGIN
T
NOT
NULL
,
third_vaccination_
number
BIGIN
T
NOT
NULL
,
country_code
VARCHAR
(
2
)
PRIMARY
KEY
,
source_id
BIGINT
NOT
NULL
,
FOREIGN
KEY
(
country_code
)
REFERENCES
Countries
(
country_code
),
...
...
@@ -91,9 +91,9 @@ CREATE TABLE Vaccinations_Per_Country(
-- keeps track of vaccinations per Region
CREATE
TABLE
Vaccinations_Per_Region
(
first_vaccination_
rate
FLOA
T
NOT
NULL
,
second_vaccination_
rate
FLOA
T
NOT
NULL
,
third_vaccination_
rate
FLOA
T
NOT
NULL
,
first_vaccination_
number
BIGIN
T
NOT
NULL
,
second_vaccination_
number
BIGIN
T
NOT
NULL
,
third_vaccination_
number
BIGIN
T
NOT
NULL
,
region_code
BIGINT
PRIMARY
KEY
,
source_id
BIGINT
NOT
NULL
,
FOREIGN
KEY
(
region_code
)
REFERENCES
Regions
(
region_code
),
...
...
@@ -102,9 +102,9 @@ CREATE TABLE Vaccinations_Per_Region(
-- keeps track of vaccinations per District
CREATE
TABLE
Vaccinations_Per_District
(
first_vaccination_
rate
FLOA
T
NOT
NULL
,
second_vaccination_
rate
FLOA
T
NOT
NULL
,
third_vaccination_
rate
FLOA
T
NOT
NULL
,
first_vaccination_
number
BIGIN
T
NOT
NULL
,
second_vaccination_
number
BIGIN
T
NOT
NULL
,
third_vaccination_
number
BIGIN
T
NOT
NULL
,
district_code
BIGINT
PRIMARY
KEY
,
source_id
BIGINT
NOT
NULL
,
FOREIGN
KEY
(
district_code
)
REFERENCES
Districts
(
district_code
),
...
...
This diff is collapsed.
Click to expand it.
initial_data_scripts/init_asia.py
+
14
−
10
View file @
0a282df4
...
...
@@ -80,9 +80,11 @@ def init_japan():
from
datetime
import
date
for
index
,
row
in
japan_v
.
iterrows
():
if
index
==
5
:
rate
=
row
[
3
]
sql
=
'''
INSERT INTO Vaccinations_Per_Country (vaccination_rate, country_code, source_id) VALUES (?, ?, ?)
'''
c
.
execute
(
sql
,(
rate
,
japan_code
,
japan_src2
))
rate1
=
row
[
2
]
rate2
=
row
[
4
]
rate3
=
row
[
6
]
sql
=
'''
INSERT INTO Vaccinations_Per_Country (first_vaccination_number, second_vaccination_number, third_vaccination_number, country_code, source_id) VALUES (?, ?, ?, ?, ?)
'''
c
.
execute
(
sql
,(
rate1
,
rate2
,
rate3
,
japan_code
,
japan_src2
))
sql
=
'''
INSERT INTO Population_Per_Country (country_code, population_amount, date_collected) VALUES (?, ?, ?)
'''
c
.
execute
(
sql
,(
japan_code
,
row
[
12
],
date
.
today
()))
break
...
...
@@ -93,9 +95,11 @@ def init_japan():
if
index
>=
6
and
index
<=
52
:
city
=
translator
.
translate
(
row
[
0
])
city
=
city
.
split
()[
1
]
rate
=
row
[
3
]
sql
=
'''
INSERT INTO Vaccinations_Per_Region (vaccination_rate, region_code, source_id) VALUES (?, ?, ?)
'''
c
.
execute
(
sql
,(
rate
,
region_dict
[
city
],
japan_src2
))
rate1
=
row
[
2
]
rate2
=
row
[
4
]
rate3
=
row
[
6
]
sql
=
'''
INSERT INTO Vaccinations_Per_Region (first_vaccination_number, second_vaccination_number, third_vaccination_number, region_code, source_id) VALUES (?, ?, ?, ?, ?)
'''
c
.
execute
(
sql
,(
rate1
,
rate2
,
rate3
,
region_dict
[
city
],
japan_src2
))
sql
=
'''
INSERT INTO Population_Per_Region (region_code, population_amount, date_collected) VALUES (?, ?, ?)
'''
c
.
execute
(
sql
,(
region_dict
[
city
],
row
[
12
],
date
.
today
()))
conn
.
commit
()
...
...
@@ -210,15 +214,15 @@ def init_korea():
#Insert population and vaccinations data for korea
sql
=
'''
INSERT INTO Population_Per_Country (country_code, population_amount, date_collected) VALUES (?, ?, ?)
'''
c
.
execute
(
sql
,(
korea_code
,
p
[
"
all
"
],
datetime
.
datetime
(
2020
,
11
,
1
).
date
()))
sql
=
'''
INSERT INTO Vaccinations_Per_Country (first_vaccination_
rate
, second_vaccination_
rate
, third_vaccination_
rate
, country_code, source_id) VALUES (?, ?, ?, ?, ?)
'''
c
.
execute
(
sql
,(
v
[
"
all
"
][
0
]
/
p
[
"
all
"
]
,
v
[
"
all
"
][
1
]
/
p
[
"
all
"
]
,
v
[
"
all
"
][
2
]
/
p
[
"
all
"
]
,
korea_code
,
korea_src
))
sql
=
'''
INSERT INTO Vaccinations_Per_Country (first_vaccination_
number
, second_vaccination_
number
, third_vaccination_
number
, country_code, source_id) VALUES (?, ?, ?, ?, ?)
'''
c
.
execute
(
sql
,(
v
[
"
all
"
][
0
],
v
[
"
all
"
][
1
],
v
[
"
all
"
][
2
],
korea_code
,
korea_src
))
conn
.
commit
()
for
city
in
region_dict
.
keys
():
city_code
=
region_dict
[
city
]
sql
=
'''
INSERT INTO Population_Per_Region (region_code, population_amount, date_collected) VALUES (?, ?, ?)
'''
c
.
execute
(
sql
,(
city_code
,
p
[
city
],
datetime
.
datetime
(
2020
,
11
,
1
).
date
()))
sql
=
'''
INSERT INTO Vaccinations_Per_Region (first_vaccination_
rate
, second_vaccination_
rate
, third_vaccination_
rate
, region_code, source_id) VALUES (?, ?, ?, ?, ?)
'''
c
.
execute
(
sql
,(
v
[
city
][
0
]
/
p
[
city
]
,
v
[
city
][
1
]
/
p
[
city
]
,
v
[
city
][
2
]
/
p
[
city
]
,
city_code
,
korea_src
))
sql
=
'''
INSERT INTO Vaccinations_Per_Region (first_vaccination_
number
, second_vaccination_
number
, third_vaccination_
number
, region_code, source_id) VALUES (?, ?, ?, ?, ?)
'''
c
.
execute
(
sql
,(
v
[
city
][
0
],
v
[
city
][
1
],
v
[
city
][
2
],
city_code
,
korea_src
))
conn
.
commit
()
conn
.
close
()
\ No newline at end of file
This diff is collapsed.
Click to expand it.
prototype_db
+
0
−
0
View file @
0a282df4
No preview for this file type
This diff is collapsed.
Click to expand it.
prototype_main_backend.py
+
9
−
10
View file @
0a282df4
...
...
@@ -83,9 +83,9 @@ c.execute('''
c
.
execute
(
'''
CREATE TABLE Vaccinations_Per_Country(
first_vaccination_
rate FLOA
T NOT NULL,
second_vaccination_
rate FLOA
T NOT NULL,
third_vaccination_
rate FLOA
T NOT NULL,
first_vaccination_
number BIGIN
T NOT NULL,
second_vaccination_
number BIGIN
T NOT NULL,
third_vaccination_
number BIGIN
T NOT NULL,
country_code VARCHAR(2) PRIMARY KEY,
source_id BIGINT NOT NULL,
FOREIGN KEY (country_code) REFERENCES Countries(country_code),
...
...
@@ -95,9 +95,9 @@ c.execute('''
c
.
execute
(
'''
CREATE TABLE Vaccinations_Per_Region(
first_vaccination_
rate FLOA
T NOT NULL,
second_vaccination_
rate FLOA
T NOT NULL,
third_vaccination_
rate FLOA
T NOT NULL,
first_vaccination_
number BIGIN
T NOT NULL,
second_vaccination_
number BIGIN
T NOT NULL,
third_vaccination_
number BIGIN
T NOT NULL,
region_code BIGINT PRIMARY KEY,
source_id BIGINT NOT NULL,
FOREIGN KEY (region_code) REFERENCES Regions(region_code),
...
...
@@ -107,9 +107,9 @@ c.execute('''
c
.
execute
(
'''
CREATE TABLE Vaccinations_Per_District(
first_vaccination_
rate FLOA
T NOT NULL,
second_vaccination_
rate FLOA
T NOT NULL,
third_vaccination_
rate FLOA
T NOT NULL,
first_vaccination_
number BIGIN
T NOT NULL,
second_vaccination_
number BIGIN
T NOT NULL,
third_vaccination_
number BIGIN
T NOT NULL,
district_code BIGINT PRIMARY KEY,
source_id BIGINT NOT NULL,
FOREIGN KEY (district_code) REFERENCES Districts(district_code),
...
...
@@ -149,6 +149,5 @@ countries = countries.rename(columns={"Name": "country_name", "Code": "country_c
countries
.
to_sql
(
'
Countries
'
,
con
=
conn
,
if_exists
=
'
append
'
,
index
=
False
)
c
.
close
()
from
initial_data_scripts.init_europe
import
init_italy
,
init_ukraine
from
initial_data_scripts.init_asia
import
init_japan
,
init_korea
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