Hello there,
i’m trying to acces data from a postgres database with the id. like this :
for x in counter_receive_last_id+1 ..counter_receive_last_id2+1 {
match db_local.query("SELECT id, date_add, date_read, astmcontent, lis_name from astm_receive where id = $1", &[&x]) {
Ok(rows) => {
for row in rows.iter() {
let entre = AstmR {
id: row.get(0),
date_add: row.get(1),
date_read: row.get(2),
astmcontent: row.get(3),
lis_name: row.get(4),
};
if entre.lis_name == lis_name {
if let Err(err) = peer1.send_to_other_peers("channel", (entre.date_add.to_string() + "/" + &entre.date_read.to_string() + "/" + &entre.astmcontent + "/" + &entre.lis_name)) {
error!("Couldn't send - received : {:?}", err);
}
}
}
}
Err(err)=> {
error!("Couldn't query - received table: {:?} ", err);
},
}
}
}
i have a function to get the id I need and it returns a i64. But the postgres query function work with {integer} type. I made those errors just to show the type of variable i use, and which is needed. the one below is the result of my function which return the id i need
error: attempted access of field `what_is_this` on type `i64`, but no field with that name was found
--> src/bin/main.rs:163:2
|
163 | counter_receive_count.what_is_this;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
when try with an {integer} it works, the following errors show the type of varible.
error: attempted access of field `what_is_this` on type `{integer}`, but no field with that name was found
--> src/bin/main.rs:181:2
|
181 | counter_receive_counta.what_is_this;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
err
also, when i run my program whis the i64 setup and i try to query a data i have this kind of error log :
ERROR:main: Couldn't query - received table: Conversion(WrongType(Int4))
Do you have an idea to how i can fix this ? thank you