key_exists <- function(service, keyring = NULL) {
return(nrow(keyring::key_list(service, keyring)) > 0)
}
get_db2 <- function(uid = NULL, pwd = NULL) {
username_key <- "username_db2"
password_key <- "password_db2"
if (key_exists(username_key) & key_exists(password_key)) {
uid <- keyring::key_get(username_key)
pwd <- keyring::key_get(password_key)
} else if (is.null(uid) | is.null(pwd)) {
uid <-
rstudioapi::showPrompt(title = "DB2 Username",
message = "DB2 Username",
default = "")
pwd <- rstudioapi::askForPassword("Database password")
}
con <- odbc::dbConnect(odbc::odbc(),
"CAM404",
uid = uid,
pwd = pwd)
return(con)
}
get_eap_postgresql <- function() {
con <- DBI::dbConnect(
RPostgres::Postgres(),
host = "192.168.15.9",
dbname = "eap",
user = rstudioapi::showPrompt(title = "xTuple Username",
message = "xTuple Username",
default = ""),
password = rstudioapi::askForPassword("Database password"),
port = 5436
)
return(con)
}
get_cam_dw <- function() {
con <- DBI::dbConnect(
odbc::odbc(),
Driver = "SQL Server",
Server = "10.100.5.3",
Database = "DataWarehouse",
Trusted_Connection = "True"
)
return(con)
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.