0

I'm working with several R files that need connect to database but server has timeout so timeout=inf is not functional

What i was looking for is something like this: RMySQL Database connection

(I'm the only user in R, and in total users just a few)

Inserting in my .RProfile all what is needed (credentials) and only in the .r programs that connect and disconnect when were necessary

In .RProfile:

con <- dbConnect(odbc::odbc(), Driver = "{MariaDB ODBC 3.1 Driver}",
         Server = "{host}", database = "db", UID = "userid",
         PWD = "pwd",
         Port = 1234)

and in .R programs use something like this:

conn <- dbConnect(odbc::odbc(), group = "what i should use here?") 

#using database
tbl(conn,"table")
#more code

dbDisconnect(conn)

I was too looking for other option, pool

In .RProfile

library(pool)
pool<- dbPool(odbc::odbc(), Driver = "{MariaDB ODBC 3.1 Driver}",
         Server = "{host}", database = "db", UID = "userid",
         PWD = "pwd",
         Port = 1234)

.Last <- function(){
poolClose(pool)
}

But i'm not sure if it works or the previous option is better.

hfa
  • 39
  • 5

0 Answers0