R/dbExistsTable__duckdb_connection_character.R

Defines functions dbExistsTable__duckdb_connection_character

Documented in dbExistsTable__duckdb_connection_character

#' @rdname duckdb_connection-class
#' @inheritParams DBI::dbExistsTable
#' @usage NULL
dbExistsTable__duckdb_connection_character <- function(conn, name, ...) {
  if (!dbIsValid(conn)) {
    stop("Invalid connection")
  }
  if (length(name) != 1) {
    stop("Can only have a single name argument")
  }
  exists <- FALSE
  tryCatch(
    {
      dbGetQuery(
        conn,
        sqlInterpolate(
          conn,
          "SELECT * FROM ? WHERE FALSE",
          dbQuoteIdentifier(conn, name)
        )
      )
      exists <- TRUE
    },
    error = function(c) {
    }
  )
  exists
}

#' @rdname duckdb_connection-class
#' @export
setMethod("dbExistsTable", c("duckdb_connection", "character"), dbExistsTable__duckdb_connection_character)

Try the duckdb package in your browser

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

duckdb documentation built on Nov. 17, 2023, 5:08 p.m.