R/dbExistsTable_MariaDBConnection_character.R

Defines functions dbExistsTable_MariaDBConnection_character

Documented in dbExistsTable_MariaDBConnection_character

#' @rdname mariadb-tables
#' @usage NULL
dbExistsTable_MariaDBConnection_character <- function(conn, name, ...) {
  stopifnot(length(name) == 1L)
  if (!dbIsValid(conn)) {
    stopc("Invalid connection")
  }
  tryCatch(
    {
      dbGetQuery(conn, paste0(
        "SELECT NULL FROM ", dbQuoteIdentifier(conn, name), " WHERE FALSE"
      ))
      TRUE
    },
    error = function(...) {
      FALSE
    }
  )
}

#' @rdname mariadb-tables
#' @export
setMethod("dbExistsTable", c("MariaDBConnection", "character"), dbExistsTable_MariaDBConnection_character)

Try the RMariaDB package in your browser

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

RMariaDB documentation built on Dec. 20, 2021, 9:06 a.m.