R/connect.R

Defines functions connect_if_valid_path

connect_if_valid_path <- function(path){
  check_file_exists(path)
  suppressWarnings(withCallingHandlers(
    conn <- readwritesqlite::rws_open_connection(dbname = path,  exists = TRUE),
    warning=function(w) {
      if (str_detect(w$message, "Couldn't set synchronous mode: file is not a database"))
        err("File provided is not an SQLite database")
    }))
  conn
}
poissonconsulting/nrp documentation built on Jan. 28, 2024, 4:14 p.m.