Skip to main content

insert_into

Function insert_into 

Source
pub fn insert_into<'q>(
    table: &str,
    map: &[(&str, &'q (dyn ToSql + Sync + 'q))],
) -> Clause<'q, Insert>
Expand description

Begin INSERT statement

§Arguments

  • table: table name
  • map: values

returns: Clause<Insert>

§Examples

insert_into("Post", &[("Id",&id),("Title", &title),("Content", &content)]).on_conflict(col("Id")).do_update_excluded(&["Title","Content"]);
// SQL: INSERT INTO "Post" ("Id","Title","Content") VALUES ($1,$2,$3) ON CONFLICT ("Id) DO UPDATE SET "Title" = excluded."Title", "Content" = excluded."Content"