I have a table toto which contains fields id uuid
and name varchar
. I want to insert data into it so I do:
use postgres::{Client, Error, NoTls};
use uuid::Uuid;
fn main() -> Result<(), Error> {
let mut client = Client::connect("host=localhost user=user dbname=dbname password='password'", NoTls)?;
let id = Uuid::new_v4();
client.execute(
"INSERT INTO toto (id, name) VALUES ($1, $2)",
&[&id, &"azert"],
)?;
Ok(())
}
In my Cargo.toml I have:
[dependencies]
uuid = { version = "0.8.2", features = ["v4"] }
postgres = { version = "0.19"}
and for the line :
&[&id, &"azert"],
and this gives me the following error:
the trait `ToSql` is not implemented for `Uuid`
How do I resolve this?