Insert struct with sqlx

Hello,

Say I have a struct Foo with a lot of fields and an associated SQL table with the same columns. Is it a better way in sqlx than doing that?

sqlx::query!(
            "INSERT INTO scored_harissa_project (
                contractor_name,
                pay_period_creation_id,
                pass_n,
               ...
                t_spent_millis,
                score,
                committed_ts
            ) VALUES (
                $1,
                $2,
               ...
                $11,
                $12,
                $13
            )",
            contractor_name,
            pay_period_creation_id,
            self.pass_n as Level,
            self.file_uuid,
            self.file_name,
           ...
            self.score,
            self.committed_ts.naive_utc()
        )
        .execute(sql_transaction)
        .await?;
2 Likes