R/dbExistsTable__duckdb_connection_ANY.R

Defines functions dbExistsTable__duckdb_connection_ANY

Documented in dbExistsTable__duckdb_connection_ANY

#' @rdname duckdb_connection-class
#' @inheritParams DBI::dbExistsTable
#' @usage NULL
dbExistsTable__duckdb_connection_ANY <- 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", "ANY"), dbExistsTable__duckdb_connection_ANY)

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.