Probleme querying stuff from postgres dbb with rust


Hello there,

I’m brand new on rust and i have a small project which aim to “replicate” some database (postgres one) between each others.

So i read this page which helped me a lot but i’m stuck at
some other point.

ATM i try to query a line with a certain ID so i have a struct matching the line :

struct  AstmR {
	id: i32,
	date_add: chrono::NaiveDateTime,
	date_read: chrono::NaiveDateTime,
	astmcontent: String,
	lis_name: String,

and when i try this block :

		for x in counter+1 .. counter2+1 {
			for row in &db1.query("SELECT id, date_add, date_read, astmcontent, lis_name from astm_receive where id = $1 ", &[&x]).unwrap(){
				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),

				db2.execute("INSERT INTO astm_receive (date_add, date_read, astmcontent, lis_name) VALUES ($1, $2, $3, $4, $5)",
				&[&entre.date_add, &entre.date_read, &entre.astmcontent, &entre.lis_name]).unwrap();

I have this king of error :

date_add: row.get(1),
             ^^^ trait `chrono::NaiveDateTime: postgres::types::FromSql` not satisfied

So here i am trying to fix this date format thing ^^ if anyone already had this probleme :slight_smile:

Thanks for the attention



Nevermind, i found the solution :

postgres = { version = "0.8", features = ["chrono"] }

i didn’t specified the chrono features :slight_smile: