OHDSI / CohortDiagnostics

An R package for performing various cohort diagnostics.
https://ohdsi.github.io/CohortDiagnostics
40 stars 45 forks source link

Document how to connect to remote database #971

Closed gowthamrao closed 1 year ago

gowthamrao commented 1 year ago

With the large size of CD output - we are more likely to need connection to remote db most of the time.

The configuration of connection will probably need a vignette, especially about how to support the various ways to manage secrets (keyring to sys.getenv).

Also - we probably need the following as defaults 1) Check if there is a local sqlite file in the data folder - if yes, use that the default with preference 1. 2) If not, and there is no other connection details -- attempt connecting to ohdsi postgres server as default - preference 2. i.e. in this case, we assume that the environment is the OHDSI Shiny server and the credentials are available to it using Sys.getenv. We might need to confirm the system global environment with @leeevans but i think they are

https://github.com/OHDSI/CohortDiagnostics/blob/befe0eb0e488fa8a4d308fed861cb03c64b67294/inst/shiny/DiagnosticsExplorer/global.R#L56-L64

dbms <- Sys.getenv("shinydbDatabase", unset = "postgresql") shinyConnectionDetails <- DatabaseConnector::createConnectionDetails( dbms = dbms, server = Sys.getenv("shinydbServer"), port = Sys.getenv("shinydbPort", unset = 5432), user = Sys.getenv("shinydbUser"), password = Sys.getenv("shinydbPw") )

gowthamrao commented 1 year ago

@azimov i think, and please confirm with @leeevans

https://github.com/OHDSI/CohortDiagnostics/blob/b8ad6d30f1766645a1c69faa57632379eefdc34e/inst/shiny/DiagnosticsExplorer/config.yml#L15-L22

@leeevans has configured database and server as one system variable. as "server/database"

i.e. the database below is NULL, and both server and database is in the server. So the code will have to be intelligent to handle that.

store connection details with environment variables

Note - if dbms and port vars are unset in environment variables they will default to above connectionDetails settings

connectionEnvironmentVariables: dbms: ~ database: ~ server: ~ user: ~ password: ~ port: ~ extraSettings: ~

gowthamrao commented 1 year ago

Another comment on same topic: i tried to deploy the shiny app on data.ohdsi.org as shown here

https://github.com/OHDSI/ShinyDeploy/blob/master/Phenotype_0002_AcutePancreatitis/config.yml#L15-L22

but am receiving this error message

image

gowthamrao commented 1 year ago

Related to https://github.com/OHDSI/CohortDiagnostics/commit/b8ad6d30f1766645a1c69faa57632379eefdc34e

azimov commented 1 year ago

Added to config readme