Skip to content
Snippets Groups Projects
Commit d271a2ab authored by Ivy Wang's avatar Ivy Wang
Browse files

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
......@@ -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)
);
......
......@@ -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()
......
......@@ -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()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment