How to iterate on serde_rusqlite

Hi

I have this struct:

#[derive(Deserialize,Serialize,Debug)]
struct CustomerAccount {
    id: i32,
    name: String,
    user_name: String,
}

And I am retrieving data from a sqlite table as follows:

let manager = SqliteConnectionManager::file("/Users/xxx/go/bin/backend/db/zerodb.db");
    let pool = r2d2::Pool::new(manager).unwrap();   

    let conn = pool.get().unwrap();
    let mut statement = conn.prepare("select id, name, username as user_name from customer_account").unwrap();
    let mut res = from_rows::<CustomerAccount>(statement.query(NO_PARAMS).unwrap());
    println!("{:?}", res.next().unwrap());

Above code works fine but I am not able to find the way to iterate to collect all the rows retrieved from the DB. I have assumed that I should use something like res.iterate() or something like that but could not find it.

Thanks in advance

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.