password in odbc connection in RShiny

380 views Asked by At

In my shiny application, in global.R I have defined an odbc connection as follow :

con <- dbConnect(odbc(),
                 DSN = 'abc',
                 Database = 'xxx',
                 UID = rstudioapi::askForPassword("Database user"),
                 PWD = rstudioapi::askForPassword("Database password")
)

The app is working when I try it from RStudio IDE, but it is not when I deploy the app on the server. The error is :

Error: RStudio not running
Execution halted

But if I change the odbc connection to :

con <- dbConnect(odbc(),
                 DSN = 'abc',
                 Database = 'xxx',
                 UID = "myuser",
                 PWD ="mypass"
)

The app will work properly. Any Idea how that could fix to avoid using the username / pass in the code ?

0

There are 0 answers