R/pins_connection.R

Defines functions pin_load.conn_open pin.connConnection

#' @export
pin.connConnection <- function(x, name = NULL, description = NULL, board = NULL, ...) {
  path <- tempfile()
  dir.create(path)
  on.exit(unlink(path))
  session <- conn_session_get(x@id)
  saveRDS(session, file.path(path, "code.rds"))
  saveRDS(
    data.frame(message = "No Viewer preview available for this type of pin"),
    file.path(path, "data.rds")
  )
  metadata <- list(
    columns = list(
      host = session$host,
      type = session$type
    )
  )
  board_pin_store(board, path, name, description, "conn_open", metadata, ...)
  # To prevent printout of x
  x <- NULL
}

#' @export
pin_load.conn_open <- function(path, ...) {
  code <- readRDS(file.path(path, "code.rds"))
  dbi_run_code(code)
}
edgararuiz/connections documentation built on Oct. 6, 2021, 8:48 a.m.