r-lib / R6

Encapsulated object-oriented programming for R
https://R6.r-lib.org
Other
403 stars 56 forks source link

Error when connecting to mariadb #229

Closed lnnq closed 3 years ago

lnnq commented 3 years ago

Hi,

I have an R6 class with a method where I connect to a mariadb database. It look something like this:

Data <- R6::R6Class( classname = "Data", public = list(

db = NULL,

connect = function() { print("Connecting to database ...") self$db <- DBI::dbConnect(RMariaDB::MariaDB(), group = "factset") print("Connected to database!") }}

When I try to connect I get this error: "Error: Failed to connect: Lost connection to MySQL server at 'handshake: reading initial communication packet', system error: 2"

The strange thing is that when I connect without the class I dont get the error and the connection get established. This works: db <- DBI::dbConnect(RMariaDB::MariaDB(), group = "factset")

Any ideas what could cause this?