2021-11-27

How to convert mysql::value::Value to other data type like f64, i32 .. in Rust?

I'm trying to get the data from the MySQL Row, the code as below

conn.query_iter("select * from TheForm")
    .unwrap()
    .for_each(|row| {
        println!("{:?}", &row.unwrap().unwrap());
    });

The output as something like that:

[Bytes("16376158.."), Bytes("55683.3"), Bytes("55739.7"), Bytes("55705.8"), Bytes("55717.7"), Bytes("5.21118")]

How can I get the data from the Array, like If I want the first index in the array, I print &row.unwrap().unwrap()[0], and the output is Bytes("16376158.."), How do I convert the Bytes to the f64, String ot other type?



from Recent Questions - Stack Overflow https://ift.tt/311RNos
https://ift.tt/eA8V8J

No comments:

Post a Comment