MCPcopy Index your code
hub / github.com/bedroombuilds/python2rust / row_to_str_vec

Function row_to_str_vec

21_postgresql/rust/pg_async/src/main.rs:16–26  ·  view source on GitHub ↗

silly way to convert row into Vec of Strings from postgres types see https://docs.rs/postgres/latest/postgres/types/trait.FromSql.html

(row: &tokio_postgres::Row)

Source from the content-addressed store, hash-verified

14/// silly way to convert row into Vec of Strings from postgres types
15/// see https://docs.rs/postgres/latest/postgres/types/trait.FromSql.html
16async fn row_to_str_vec(row: &tokio_postgres::Row) -> Vec<String> {
17 (0..row.len())
18 .into_iter()
19 .map(|ci| match *row.columns().get(ci).unwrap().type_() {
20 Type::DATE => row.get::<usize, chrono::NaiveDate>(ci).to_string(),
21 Type::INT4 => row.get::<usize, i32>(ci).to_string(),
22 Type::INT8 => row.get::<usize, i64>(ci).to_string(),
23 _ => "blah".to_string(),
24 })
25 .collect()
26}
27
28async fn row_to_str_hashmap(row: &tokio_postgres::Row) -> HashMap<String, String> {
29 let values = row_to_str_vec(row).await;

Callers 1

row_to_str_hashmapFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected