read_cnt {connector} | R Documentation |
Read content from the connector
Description
Generic implementing of how to read content from the different connector objects:
-
ConnectorDBI: Uses
DBI::dbReadTable()
to read the table from the DBI connection.
-
ConnectorFS: Uses
read_file()
to read a given file. The underlying function used, and thereby also the arguments available through...
depends on the file extension.
Usage
read_cnt(connector_object, name, ...)
## S3 method for class 'ConnectorDBI'
read_cnt(connector_object, name, ...)
## S3 method for class 'ConnectorFS'
read_cnt(connector_object, name, ...)
Arguments
connector_object |
Connector The connector object to use. |
name |
character Name of the content to read, write, or remove. Typically the table name. |
... |
Additional arguments passed to the method for the individual connector. |
Value
R object with the content. For rectangular data a data.frame.
Examples
# Read table from DBI database
cnt <- connector_dbi(RSQLite::SQLite())
cnt |>
write_cnt(iris, "iris")
cnt |>
list_content_cnt()
cnt |>
read_cnt("iris") |>
head()
# Write and read a CSV file using the file storage connector
folder <- withr::local_tempdir()
cnt <- connector_fs(folder)
cnt |>
write_cnt(iris, "iris.csv")
cnt |>
read_cnt("iris.csv") |>
head()
[Package connector version 0.1.1 Index]