etl_init | R Documentation |
Initialize a database using a defined schema
etl_init(
obj,
script = NULL,
schema_name = "init",
pkg = attr(obj, "pkg"),
ext = NULL,
...
)
## Default S3 method:
etl_init(
obj,
script = NULL,
schema_name = "init",
pkg = attr(obj, "pkg"),
ext = NULL,
...
)
find_schema(obj, schema_name = "init", pkg = attr(obj, "pkg"), ext = NULL, ...)
obj |
An |
script |
either a vector of SQL commands to be executed, or
a file path as a character vector containing an SQL initialization script.
If |
schema_name |
The name of the schema. Default is |
pkg |
The package defining the schema. Should be set in |
ext |
The file extension used for the SQL schema file. If NULL (the default) it
be inferred from the |
... |
Currently ignored |
If the table definitions are at all non-trivial, you may wish to include a pre-defined table schema. This function will retrieve it.
cars <- etl("mtcars")
cars %>%
etl_init()
cars %>%
etl_init(script = sql("CREATE TABLE IF NOT EXISTS mtcars_alt (id INTEGER);"))
cars %>%
etl_init(schema_name = "init")
init_script <- find_schema(cars, schema_name = "init")
cars %>%
etl_init(script = init_script, echo = TRUE)
src_tbls(cars)
cars <- etl("mtcars")
find_schema(cars)
find_schema(cars, "init", "etl")
find_schema(cars, "my_crazy_schema", "etl")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.