I am using RStudio Server and ODBC to connect to a redshift database. I can connect easily using:
conn <- dbConnect(odbc::odbc(), Driver="redshift",
Server = SERVER_URL,
Port = "5439",
Database = DB_NAME,
PWD = PASSWORD,
UID = CREDENTIALS,
timeout = 10,
Trusted_Connection = "True")
When connected in shows up in the pane/sidebar "connections" where I have an UI to look through the database. That is exactly what i want.
The problem is that if i call the same code inside a function, then I get the database connection but no UI?!? How do i get the UI to appear when calling this code from inside a function?
C
onnection_odbc_profile <- function(INPUT){
conn <- dbConnect(odbc::odbc(), Driver="redshift",
Server = SERVER_URL,
Port = "5439",
Database = DB_NAME,
PWD = PASSWORD,
UID = CREDENTIALS,
timeout = 10,
Trusted_Connection = "True")
return(conn)
}
I think the issue is that the connection pane only gets updated when the code is run at top-level. Is there any way to force a line of code in a function to run at top-level (or directly in the console). I have not been able to find a solution online and i think its a bug if its not possible to set up the odbc database UI just because the connection is made inside a function...