Learn R Programming

connector (version 0.1.0)

write_cnt: Write content to the connector

Description

Generic implementing of how to write content to the different connector objects:

  • ConnectorFS: Uses write_file() to Write a file based on the file extension. The underlying function used, and thereby also the arguments available through ... depends on the file extension.

Usage

write_cnt(
  connector_object,
  x,
  name,
  overwrite = zephyr::get_option("overwrite", "connector"),
  ...
)

# S3 method for ConnectorDBI write_cnt( connector_object, x, name, overwrite = zephyr::get_option("overwrite", "connector"), ... )

# S3 method for ConnectorFS write_cnt( connector_object, x, name, overwrite = zephyr::get_option("overwrite", "connector"), ... )

Value

invisible connector_object.

Arguments

connector_object

Connector The connector object to use.

x

The object to write to the connection

name

character Name of the content to read, write, or remove. Typically the table name.

overwrite

Overwrite existing content if it exists in the connector?. Default: FALSE.

...

Additional arguments passed to the method for the individual connector.

Examples

Run this code
# Write table to DBI database
cnt <- connector_dbi(RSQLite::SQLite())

cnt |>
  list_content_cnt()

cnt |>
  write_cnt(iris, "iris")

cnt |>
  list_content_cnt()

# Write different file types to a file storage

folder <- withr::local_tempdir()
cnt <- connector_fs(folder)

cnt |>
  list_content_cnt(pattern = "iris")

# rds file
cnt |>
  write_cnt(iris, "iris.rds")

# CSV file
cnt |>
  write_cnt(iris, "iris.csv")

cnt |>
  list_content_cnt(pattern = "iris")

Run the code above in your browser using DataLab