#' Start connection
#'
#' Start a connection to a database (SQL Server).
#'
#'
#' @param database Name of database as a string, either "analyse" or "patient_kval".
#'
#' @return A connection object. Remember to make an assignment e.g. con <- con_start("analyse").
#' @export
con_start <- function(database = "analyse"){
if (length(database) != 1 || is.numeric(database) || is.logical(database)){
stop('Pass database name as a string, i.e. put in quotation mark.\n Use either "analyse" or "patient_kval".')
}
else if (database == "analyse"){
con <- DBI::dbConnect(odbc::odbc(),
Driver = "SQL Server",
Server = "RGHPRODAPP007\\RGHPRODAPP007",
Database = "Analyse",
Trusted_Connection = "True",
encoding = "latin1")
} else if (database=="patient_kval"){
con <- DBI::dbConnect(odbc::odbc(),
Driver = "SQL Server",
Server = "RGHPRODAPP006\\RGHPRODAPP006",
Database = "Patient_kval",
Trusted_Connection = "True",
encoding = "latin1")
} else {
message('Use either "analyse", or "patient_kval".')
}
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.