I would like to use the arguments used for the dbPool connection inside another function without having to provide the information again.
I have tried to use dbConnectArgs but I wasn’t able to make it work. I would like to be able to retrieve the ‘database’ and ´server’ arguments from the dbPool connection.
Here is an example of my dbPool connection :
connection <- pool::dbPool(
drv = odbc::odbc(),
driver = <driver name>,
database = <database name>,
UID = <username>,
PWD = <password>,
server = <server name>,
port = <port>,
minsize = 0,
idleTimeout = 600,
encoding = "UTF-8",
Authentication = <authentication method>,
encrypt = "yes"
)
So I would need to get "database name" and "server name" minimally. Is there a function/method to get this information?
So I have found the solution! By evalutating the the connection object we can retrieve a S4 object. Here’s how :
object <- eval(connection$fetch())
servername <- object@info$servername
dbname <- object@info$dbname