Skip to content

Commit

Permalink
commit v2.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
ZorzArg committed Sep 17, 2024
1 parent ac95257 commit 133d328
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 5 deletions.
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# EHDEN HMB v2.3.1

* Added Redshift connectivity in function `cdmFromConAllDbs`
* Updated the `KeyringSetup.R` file to add two additional credentials: port and server

# EHDEN HMB v2.3.0

* Added function `cdmFromConAllDbs` to connect to different SQL servers with ODBC drivers
Expand Down
28 changes: 25 additions & 3 deletions analysis/private/_incidenceAnalysis.R
Original file line number Diff line number Diff line change
Expand Up @@ -266,14 +266,36 @@ cdmFromConAllDbs <- function(executionSettings) {
}


## Postgre
## PostgreSql
if (executionSettings$dbms == "postgresql") {

## Connect to server
con <- DBI::dbConnect(
drv = RPostgres::Postgres(),
host = host,
port = 5441,
host = executionSettings$server,
port = executionSettings$port,
dbname = dbName,
user = executionSettings$user,
password = executionSettings$password
)

## Connect to database
cdm <- cdm_from_con(
con = con,
cdm_schema = schemaName,
write_schema = writeSchemaName
)

}

## Redshift
if (executionSettings$dbms == "redshift") {

## Connect to server
con <- DBI::dbConnect(
drv = RPostgres::Redshift(),
host = executionSettings$server,
port = executionSettings$port,
dbname = dbName,
user = executionSettings$user,
password = executionSettings$password
Expand Down
18 changes: 18 additions & 0 deletions analysis/private/_utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,21 @@ zipResults <- function(database) {
crayon::cyan(here::here(paste0(zipName, ".zip"))),bullet = "info", bullet_col = "blue")

}


defaultCreds <- function() {

creds <- c(
"dbms", # the database dialect
"user", # the user name for the db
"password", # the password for the db
"port",
"server",
"connectionString", # the connection string to access the db
"cdmDatabaseSchema", # the database + schema (or just schema) hosting the cdm
"vocabDatabaseSchema", # the database + schema (or just schema) hosting the vocabulary, usually same as cdm
"workDatabaseSchema" # the database + schema (or just schema) hosting the work or scratch
)

return(creds)
}
4 changes: 2 additions & 2 deletions extras/KeyringSetup.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
library(tidyverse, quietly = TRUE)
library(Ulysses)
library(keyring)

source("analysis/private/_utilities.R")

## B. Set Parameters ------------

Expand All @@ -36,7 +36,7 @@ setStudyKeyring(keyringName = keyringName,
keyringPassword = keyringPassword)

### Set credential keys in keyring
setMultipleCredentials(cred = defaultCredentials(),
setMultipleCredentials(cred = defaultCreds(),
db = configBlock,
keyringName = keyringName,
keyringPassword = keyringPassword,
Expand Down

0 comments on commit 133d328

Please sign in to comment.