R/import.Postgres.Identifier.R

Defines functions db.get.by.identifier

#' import postgres data by identifier
#'
#' @description This function imports data
#' @param file is the sql script.
#' @param identifier is a vector of unique "Teilantragsnummern"
#' @return datatframe, tibble
#' @keywords import
#' @import DBI, readr
#' @export
#' @examples loadByQuery("yourSQLScript.sql", startDate = startDate, endDate = endDate)

db.get.by.identifier <- function(file, identifier) {
  # enrich payment data with additional atributes from redshift
  # selection is based on unique 'teilantragsnummer'

  preparedStatement <-as.factor(paste0("'", identifier, "'", collapse = ','))
  select <- DBI::sqlInterpolate(DBI::ANSI(), readr::read_file(paste0(getwd(),
                                                                     file)),  teilantragsnummer = preparedStatement)
  result <- dbGetQuery(connPostgres, select)

  return(result)
}
europace-privatkredit/tidyPkuData documentation built on Oct. 2, 2019, 3 a.m.