When i make a connection to a database using the DBI package in the following way:
con <- DBI::dbConnect(odbc::odbc(), dsn=server, uid=uid, pwd=pwd, timeout = 10)
A connection is made and all tables are displayed in the connections tab of rstudio.
However, If i run the same command in a function like this:
test <- function(){
con <- DBI::dbConnect(odbc::odbc(), dsn=server, uid=uid, pwd=pwd, timeout = 10)
return(con)
}
then a connection made to the database but it is not registered in the connection pane. Hence no tables are shown
Why is this?
thanks