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
d271a2ab
Commit
d271a2ab
authored
3 years ago
by
Ivy Wang
Browse files
Options
Downloads
Patches
Plain Diff
add other rate for strain table and create table for all three strain table
parent
a5087f56
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
data/OverallSchema.sql
+3
-0
3 additions, 0 deletions
data/OverallSchema.sql
initial_data_scripts/init_north_america.py
+3
-2
3 additions, 2 deletions
initial_data_scripts/init_north_america.py
run_main_initial.py
+33
-0
33 additions, 0 deletions
run_main_initial.py
with
39 additions
and
2 deletions
data/OverallSchema.sql
+
3
−
0
View file @
d271a2ab
...
...
@@ -121,6 +121,7 @@ CREATE TABLE Strains_Per_Country(
gamma_rate
FLOAT
NULL
,
delta_rate
FLOAT
NULL
,
omicron_rate
FLOAT
NULL
,
other_rate
FLOAT
NULL
,
FOREIGN
KEY
(
country_code
)
REFERENCES
Countries
(
country_code
),
FOREIGN
KEY
(
source_id
)
REFERENCES
Sources
(
source_id
));
...
...
@@ -135,6 +136,7 @@ CREATE TABLE Strains_Per_Region(
gamma_rate
FLOAT
NULL
,
delta_rate
FLOAT
NULL
,
omicron_rate
FLOAT
NULL
,
other_rate
FLOAT
NULL
,
FOREIGN
KEY
(
region_code
)
REFERENCES
Regions
(
region_code
),
FOREIGN
KEY
(
source_id
)
REFERENCES
Sources
(
source_id
)
);
...
...
@@ -149,6 +151,7 @@ CREATE TABLE Strains_Per_District(
gamma_rate
FLOAT
NULL
,
delta_rate
FLOAT
NULL
,
omicron_rate
FLOAT
NULL
,
other_rate
FLOAT
NULL
,
FOREIGN
KEY
(
district_code
)
REFERENCES
Districts
(
district_code
),
FOREIGN
KEY
(
source_id
)
REFERENCES
Sources
(
source_id
)
);
...
...
This diff is collapsed.
Click to expand it.
initial_data_scripts/init_north_america.py
+
3
−
2
View file @
d271a2ab
...
...
@@ -194,8 +194,9 @@ def init_canada():
ca_strain
[
row
[
"
Collection (week)
"
]]
=
{
"
Alpha
"
:
0
,
"
Beta
"
:
0
,
"
Gamma
"
:
0
,
"
Delta
"
:
0
,
"
Omicron
"
:
0
}
ca_strain
[
row
[
"
Collection (week)
"
]][
row
[
"
_Identifier
"
]]
=
ca_strain
[
row
[
"
Collection (week)
"
]][
row
[
"
_Identifier
"
]]
+
row
[
"
%CT Count of Sample #
"
]
for
date
in
ca_strain
:
sql
=
'''
INSERT INTO Strains_Per_Country (date_collected, country_code, source_id, alpha_rate, beta_rate, gamma_rate, delta_rate, omicron_rate) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
'''
c
.
execute
(
sql
,(
date
,
ca_code
,
ca_src
,
ca_strain
[
date
][
"
Alpha
"
],
ca_strain
[
date
][
"
Beta
"
],
ca_strain
[
date
][
"
Gamma
"
],
ca_strain
[
date
][
"
Delta
"
],
ca_strain
[
date
][
"
Omicron
"
]))
other_rate
=
max
(
1
-
ca_strain
[
date
][
"
Alpha
"
]
-
ca_strain
[
date
][
"
Beta
"
]
-
ca_strain
[
date
][
"
Gamma
"
]
-
ca_strain
[
date
][
"
Delta
"
]
-
ca_strain
[
date
][
"
Omicron
"
],
0
)
sql
=
'''
INSERT INTO Strains_Per_Country (date_collected, country_code, source_id, alpha_rate, beta_rate, gamma_rate, delta_rate, omicron_rate, other_rate) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)
'''
c
.
execute
(
sql
,(
date
,
ca_code
,
ca_src
,
ca_strain
[
date
][
"
Alpha
"
],
ca_strain
[
date
][
"
Beta
"
],
ca_strain
[
date
][
"
Gamma
"
],
ca_strain
[
date
][
"
Delta
"
],
ca_strain
[
date
][
"
Omicron
"
],
other_rate
))
conn
.
commit
()
...
...
This diff is collapsed.
Click to expand it.
run_main_initial.py
+
33
−
0
View file @
d271a2ab
...
...
@@ -219,12 +219,45 @@ c.execute('''CREATE TABLE Strains_Per_Country(
gamma_rate FLOAT NULL,
delta_rate FLOAT NULL,
omicron_rate FLOAT NULL,
other_rate FLOAT NULL,
FOREIGN KEY (country_code) REFERENCES Countries(country_code),
FOREIGN KEY (source_id) REFERENCES Sources(source_id)
);
'''
)
c
.
execute
(
'''
CREATE TABLE Strains_Per_Region(
date_collected DATETIME2 NOT NULL,
region_code BIGINT,
source_id INT NOT NULL,
alpha_rate FLOAT NULL,
beta_rate FLOAT NULL,
gamma_rate FLOAT NULL,
delta_rate FLOAT NULL,
omicron_rate FLOAT NULL,
other_rate FLOAT NULL,
FOREIGN KEY (region_code) REFERENCES Regions(region_code),
FOREIGN KEY (source_id) REFERENCES Sources(source_id)
);
'''
)
c
.
execute
(
'''
CREATE TABLE Strains_Per_District(
date_collected DATETIME2 NOT NULL,
district_code BIGINT,
source_id INT NOT NULL,
alpha_rate FLOAT NULL,
beta_rate FLOAT NULL,
gamma_rate FLOAT NULL,
delta_rate FLOAT NULL,
omicron_rate FLOAT NULL,
other_rate FLOAT NULL,
FOREIGN KEY (district_code) REFERENCES Districts(district_code),
FOREIGN KEY (source_id) REFERENCES Sources(source_id)
);
'''
)
conn
.
commit
()
...
...
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