RMySQL: internal error in RS_DBI_getConnection: damaged connection handle

So, I first connected to my database:

con <- dbConnect(
MySQL(),
user = "username", password = "password",
host = "<my amazon web service database server>",
port = 3306
)

So, everything worked, but after the pair is working / updating in my Shiny application, it says that I have 16 connections open and I can no longer open any connections.

So, I tried to work:

dbDisconnect(dbListConnections(MySQL()))

Then I got the following:

dbListConnections(MySQL())
[[1]]TRUE

Then I got this error:

Error in .local(dbObj, ...) : 
internal error in RS_DBI_getConnection: corrupt connection handle

Now when I try to open my Shiny application, I get a datatableoutput error message

(I query the database to generate this output):
internal error in RS_DBI_getConnection: corrupt connection handle
+4
source share
1 answer

I had the same problem. Here's how I solved it:

, , . , :

con <- dbConnect(
  MySQL(),
  ...
)

MyFunction <- function(){
  myQuery <- paste("SELECT * FROM ...")
  df <- dbGetQuery(con, myQuery)
  df
}

, "16", ( ).

:

MyFunction <- function(){

  con <- dbConnect(
    MySQL(),
    ...
  )

  myQuery <- paste("SELECT * FROM ...")
  df <- dbGetQuery(con, myQuery)

  dbDisconnect(con)
  df
}

.

+1

Source: https://habr.com/ru/post/1617167/


All Articles