Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
jgoerzen committed Jul 8, 2021
1 parent 166ca58 commit 93c6d80
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/dbschema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,8 @@ pub async fn initdb<E: Executor>(db: &mut E) -> () {
handwashing_facilities real,
hospital_beds_per_thousand real,
life_expectancy real,
human_development_index
human_development_index,
excess_mortality
)",
"CREATE UNIQUE INDEX owid_raw_uniq_idx ON owid_raw (date_julian, iso_code)",
];
Expand Down
4 changes: 3 additions & 1 deletion src/dbschema/owid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ pub struct OWID {
pub hospital_beds_per_thousand: Option<f64>,
pub life_expectancy: Option<f64>,
pub human_development_index: Option<f64>,
pub excess_mortality: Option<f64>,
}

impl OWID {
Expand Down Expand Up @@ -151,11 +152,12 @@ impl OWID {
.bind(self.hospital_beds_per_thousand)
.bind(self.life_expectancy)
.bind(self.human_development_index)
.bind(self.excess_mortality)
}

/// Gets an INSERT INTO string representing all the values in the table.
pub fn insert_str() -> &'static str {
"INSERT INTO owid_raw VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
"INSERT INTO owid_raw VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)"
}

/// Sets all date fields in the struct to appropriate representations of the
Expand Down
5 changes: 4 additions & 1 deletion src/loader/owidloader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ pub struct OWIDRecord {
pub hospital_beds_per_thousand: Option<f64>,
pub life_expectancy: Option<f64>,
pub human_development_index: Option<f64>,
pub excess_mortality: Option<f64>,
}

pub fn parse_to_final<A: Iterator<Item = csv::StringRecord>>(
Expand Down Expand Up @@ -159,7 +160,8 @@ pub async fn load<'a, A: std::io::Read>(
"handwashing_facilities",
"hospital_beds_per_thousand",
"life_expectancy",
"human_development_index"
"human_development_index",
"excess_mortality",
],
rdr.headers().unwrap().iter().collect::<Vec<&str>>()
);
Expand Down Expand Up @@ -227,6 +229,7 @@ pub async fn load<'a, A: std::io::Read>(
hospital_beds_per_thousand: rec.hospital_beds_per_thousand,
life_expectancy: rec.life_expectancy,
human_development_index: rec.human_development_index,
excess_mortality: rec.excess_mortality,
};
let query = sqlx::query(OWID::insert_str());
dbrec
Expand Down

0 comments on commit 93c6d80

Please sign in to comment.