use mysql::*;
use mysql::prelude::*;
fnmain() {
let pool = mysql::Pool::new("mysql://username:password@localhost/dbname").unwrap();
letmut conn = pool.get_conn().unwrap();
let query = "SELECT name, age FROM users WHERE id = ?";
let params = (1,);
let query_result: QueryResult<Row> = conn.exec_first(query, params).unwrap();
match query_result {
Some(row) => {
let name: String = row.get("name").unwrap();
let age: i32 = row.get("age").unwrap();
println!("Name: {}, Age: {}", name, age);
},
None => println!("User not found."),
}
}