Not able to pass data to postgres database using actix

pub async fn add_plant_data(client: web::Data<Client>,
        plant_data: web::Json<PlantDataResponse>,) -> HttpResponse {

        let _stmt = include_str!("../sql/add_plantdata.sql");
        let _stmt = _stmt.replace("$table_fields", &PlantDataResponse::sql_table_fields());
        let stmt = client.prepare(&_stmt).await.unwrap();
        
       

        // let created_time = DateTime::parse_from_rfc3339(&plant_data.created_time.to_rfc3339())
        //     .unwrap_or_else(|_| Utc::now().into())
        //     .with_timezone(&Utc);
        
        //  println!("{}, {}, {}, {}", plant_data.plant_id, plant_data.created_time, plant_data.quality, plant_data.performance);

        match client
            .execute(
                &stmt,
                &[
                    &plant_data.plant_id,
                    &plant_data.created_time,
                    &plant_data.quality,
                    &plant_data.performance,
                ],
            )
            .await
        {
            Ok(_) => HttpResponse::Ok().finish(),
            Err(_) => HttpResponse::InternalServerError().finish(),
        }
    }

for above code I have following schema and query

CREATE TABLE testing.plantdata (
    plant_id        VARCHAR(50) NOT NULL,
    created_time    TIMESTAMP,
    quality         INTEGER NOT NULL,
    performance     INTEGER NOT NULL
);
INSERT INTO testing.plantdata (plant_id, created_time, quality, performance)
VALUES ($1, $2, $3, $4)

But I am not able to add the data to database, what is the issue.
Please help and let me know what changes should i do.

Specifically how? Are you getting a compiler error? A runtime error? If so, specifically what?

I am not getting any error. Only the data is not added in database.

Are you doing this in a transaction? If so, are you sure the transaction is committed successfully? Do you see the connection being established in the log of your postgres process? Are you sure you are connecting to the correct instance, the correct database, and the correct schema?

yes the database is connected, correct instance and schema.

Don't know what is the issue actually taking place.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.