I wrote a function that allows me to connect to multiple databases at once and then store the connections in a list so that I can call them as needed for each individual project. The function is working great and I've been able to return data from all the databases that I've attempted to connect to (so far up to 3 at once), but it looks like storing this type of connection in a list is deprecated and I got the following error/warning messages.
Error in (function (classes, fdef, mtable) :
unable to find an inherited method for function ‘dbGetQuery’ for signature ‘"list", "character"’
In addition: Warning messages:
1: In `[<-`(`*tmp*`, i, value = new("JDBCConnection", jc = new("jobjRef", :
implicit list embedding of S4 objects is deprecated
2: In `[<-`(`*tmp*`, i, value = new("JDBCConnection", jc = new("jobjRef", :
implicit list embedding of S4 objects is deprecated
3: In `[<-`(`*tmp*`, i, value = new("JDBCConnection", jc = new("jobjRef", :
implicit list embedding of S4 objects is deprecated
What would be the non-deprecated or best practice way to accomplish this?
I'm not sure what your issue is.
A reprex would likely help.
In general you can put s4 objects into a list. not sure what implicit list embedding means though.
setClass("Person", representation(name = "character", age = "numeric"))
hadley <- new("Person", name = "Hadley", age = 31)
nirgrahamuk <- new("Person",name="Nir",age=38)
mylist_of_people <- list(hadley,
nirgrahamuk)
mylist_of_people[[1]]
mylist_of_people[[2]]