()
| 35 | } |
| 36 | |
| 37 | fn main() -> Result<(), Error> { |
| 38 | let mut client = Client::connect("host=localhost user=htd", NoTls)?; |
| 39 | |
| 40 | let rows = client.query(MOST_RECOVERED, &[])?; |
| 41 | |
| 42 | let value: chrono::NaiveDate = rows[0].get(0); |
| 43 | println!("{:?}", value); |
| 44 | println!("{:?}", row_to_str_vec(&rows[0])); |
| 45 | println!("{:?}", row_to_str_hashmap(&rows[0])); |
| 46 | |
| 47 | let mut transaction = client.transaction()?; |
| 48 | transaction.query("DELETE FROM month_cases", &[])?; |
| 49 | let ins_mv = transaction.prepare( |
| 50 | "INSERT INTO month_cases |
| 51 | (mon, new_cases, recovered) |
| 52 | VALUES ($1, $2, $3)", |
| 53 | )?; |
| 54 | for row in transaction.query(GROUP_BY_MONTH, &[])? { |
| 55 | println!("{:?}", row_to_str_vec(&row)); |
| 56 | let date: chrono::NaiveDate = row.get(0); |
| 57 | let new_cases: i64 = row.get(1); |
| 58 | let recovered: i64 = row.get(2); |
| 59 | transaction.execute( |
| 60 | &ins_mv, |
| 61 | &[&date.to_string(), &(new_cases as i32), &(recovered as i32)], |
| 62 | )?; |
| 63 | } |
| 64 | transaction.commit()?; |
| 65 | Ok(()) |
| 66 | } |
nothing calls this directly
no outgoing calls
no test coverage detected