Skip to contents

This function adds a new datasource to a YAML configuration file by appending the provided datasource information to the existing datasources.

Usage

add_datasource(config_path, name, backend)

Arguments

config_path

The file path to the YAML configuration file

name

The name of the new datasource

backend

A named list representing the backend configuration for the new datasource

Value

The updated configuration after adding the new datasource

Examples


# Read the YAML file
test_config <- system.file("config", "default_config.yml", package = "connector")
file.copy(test_config, "test_config.yaml")
#> [1] TRUE

# Add a new datasource
# Define the backend as a named list
new_backend <- list(
  type = "connector_jdbc",
  driver = "org.postgresql.Driver",
  url = "jdbc:postgresql://localhost:5432/mydatabase",
  user = "username",
  password = "password"
)

# Add a new datasource with the defined backend
config <- add_datasource("test_config.yaml", "new_datasource", new_backend)

unlink("test_config.yaml")