tests/testthat/test-register_readonly.R

test_that("we can register a data frame on a read only connection", {
  path <- tempfile()
  # create empty database
  con <- dbConnect(duckdb(), dbdir = path, read_only = FALSE)
  dbDisconnect(con, shutdown = TRUE)

  # reopen database read-only, try to write temp table
  con <- dbConnect(duckdb(), dbdir = path, read_only = TRUE)
  expect_true(duckdb_register(con, "mtcars", mtcars))
  dbDisconnect(con, shutdown = TRUE)
})

Try the duckdb package in your browser

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

duckdb documentation built on Oct. 30, 2024, 5:06 p.m.