tests/testthat/test-readonly.R

test_that("read-only databases forbid writes", {
  con <- dbConnect(SQLite(), ":memory:", flags = SQLITE_RO)
  on.exit(dbDisconnect(con), add = TRUE)

  expect_error(
    dbWriteTable(con, "mtcars", mtcars),
    "attempt to write a readonly database",
    fixed = TRUE
  )
})

Try the RSQLite package in your browser

Any scripts or data that you put into this service are public.

RSQLite documentation built on May 29, 2024, 3:30 a.m.