pub type RowSet = RowSet;
Expand description
The result of a database query.
§Examples
Load a set of rows from a local PostgreSQL database, and iterate over them selecting one field from each. The columns collection allows you to find column indexes for column names; you can bypass this lookup if you name specific columns in the query.
use spin_sdk::mysql::{Connection, Decode, ParameterValue};
let db = Connection::open("mysql://root:my_password@localhost/mydb")?;
let query_result = db.query(
"SELECT * FROM users WHERE age >= ?",
&[ParameterValue::Int32(min_age)]
)?;
let name_index = query_result.columns.iter().position(|c| c.name == "name").unwrap();
for row in &query_result.rows {
let name = String::decode(&row[name_index])?;
println!("Found user {name}");
}
Aliased Type§
struct RowSet { /* private fields */ }