Skip to contents

Reproduce your workflow by creating a config file based on a connectors object and the associated datasource attributes.

Usage

write_datasources(connectors, file)

Arguments

connectors

A connectors object with associated "datasources" attribute.

file

path to the config file

Value

A config file with datasource attributes which can be reused in the connect function

Examples


# Connect to the datasources specified in it
config <- system.file("config", "default_config.yml", package = "connector")
cnts <- connect(config)
#> ────────────────────────────────────────────────────────────────────────────────
#> Connection to:
#>adam
#>  connector_fs
#>  /home/runner/work/_temp/Library/connector/demo_trial/adam and test2
#> ────────────────────────────────────────────────────────────────────────────────
#> Connection to:
#>sdtm
#>  connector_dbi
#>  RSQLite::SQLite() and :memory:

# Extract the datasources to a config file
yml_file <- tempfile(fileext = ".yml")
write_datasources(cnts, yml_file)

# Reconnect using the new config file
re_connect <- connect(yml_file)
#> ────────────────────────────────────────────────────────────────────────────────
#> Connection to:
#>adam
#>  connector_fs
#>  /home/runner/work/_temp/Library/connector/demo_trial/adam and test2
#> ────────────────────────────────────────────────────────────────────────────────
#> Connection to:
#>sdtm
#>  connector_dbi
#>  RSQLite::SQLite() and :memory:
re_connect
#> <connectors>
#>   $adam <test2>
#>   $sdtm <connector_dbi>