# if you need a new package, you should add it with renv::install(package) so your renv venv is updated
library(RMariaDB)
library(yaml)
#' @description
#' Auxiliary function to parse the connection credentials from a specifc group in ./credentials.yaml
#' You can reause most of this function if you are connection to a DB or Web API.
#' It's OK to delete this function if you don't need credentials, e.g., you are pulling data from a CSV for example.
#' @param group the yaml key containing the credentials to connect to a database
#' @preturn dbEngine a database engine (connection) ready to perform queries
get_db_engine<-function(group){
# The working dir is aways RAPIDS root folder, so your credentials file is always /credentials.yaml
credentials<-read_yaml("./credentials.yaml")
if(!group%in%names(credentials))
stop(paste("The credentials group",group,"does not exist in ./credentials.yaml. The only groups that exist in that file are:",paste(names(credentials),collapse=",")))