generate_yaml: Generate a YAML file for SQL loading based on in a data.frame...

View source: R/utilities.R

generate_yamlR Documentation

Generate a YAML file for SQL loading based on in a data.frame or data.table

Description

YAML files can be helpful for uploading data to SQL efficiently and correctly. This function should enable the user to create a standard YAML file that be be used to push data from R to SQL.

This function expects data in the form of a data.frame or data.table

Usage

generate_yaml(
  mydt,
  outfile = NULL,
  datasource = NULL,
  schema = NULL,
  table = NULL
)

Arguments

mydt

the name of a data.table or data.frame for which you want to create a YAML file

outfile

optional character vector of length one. The complete filepath for where the *.yaml file should be saved. If it is not specified, the YAML file will be returned in memory

datasource

A character vector of length one. A human readable description of the datasource to be uploaded to SQL. This could be a filepath to the original data on a shared drive or a simple description.

schema

A character vector of length one. The schema to be used within the specific server and database that will be specified in your odbc connection.

table

A character vector of length one. The table to be used within the specific server and database that will be specified in your odbc connection and within the schema that you specified above.

Value

a list with the YAML file contents (if outfile not specified) or a message stating where the YAML file has been saved (if outfile was specified)

Examples



data(mtcars)
# output to object in memory
  check <- generate_yaml(mtcars, schema = "SCH", table = "TBL",
  datasource = "R standard mtcars")
# output to a file
  output_file <- tempfile('output_file', fileext = ".yaml")
  generate_yaml(mtcars, outfile = output_file, schema = "SCH", table = "TBL",
  datasource = "R standard mtcars")



PHSKC-APDE/rads documentation built on April 14, 2025, 10:47 a.m.