My function contained in a larger function uses dbConnect(), dbGetQuery()and dbDisconnect().
When a function error fails, I fix it and try to restart it. I can not repeat it because I get:
Error in mysqlCloseConnection(conn, ...) :
connection has pending rows (close open results set first)
(Note 1: I do not use dbSendQuery()+ fetch(), simply dbGetQuery(), so this is a strange error in itself.)
(Note 2: Errors DO NOT occur in the code RMySQL, they occur in other parts of the R-code.)
Unsuccessful solution 1: dbClearResult(dbListResults(myconnection)[[1]])does not work, because it was created inside the function environment myconnection.
Unsuccessful solution 2: lapply( dbListConnections( dbDriver( drv = "MySQL")), dbDisconnect)errors with the same error message "deferred lines" above.
My only solution now is to kill R and start over. However, I know that the connection still exists in the SQL database (because my boss tells me so), so I am looking for a suitable solution to close the result / connection.
Thanks for any help.
source
share