library(dplyr)
con <- DBI::dbConnect(RSQLite::SQLite(), ":memory:")
DBI::dbExecute(con, "CREATE TABLE Info (
id INTEGER PRIMARY KEY AUTOINCREMENT,
number INTEGER
)")
info <- tbl(con, "Info")
rows1 <- copy_inline(con, data.frame(number = c(1, 5)))
rows_insert(info, rows1, conflict = "ignore", in_place = TRUE)
info
# If the table has an auto incrementing primary key, you can use
# the returning argument + `get_returned_rows()` its value
rows2 <- copy_inline(con, data.frame(number = c(13, 27)))
info <- rows_insert(
info,
rows2,
conflict = "ignore",
in_place = TRUE,
returning = id
)
info
get_returned_rows(info)
Run the code above in your browser using DataLab