For instance, if I need to implement a connection pool within a package, how should I proceed?
Previously, I created pool::dbPool() in the .onLoad() function and closed it with reg.finalizer(), which worked well. However, adding more data sources would clutter the .onLoad() function. Also, how can I establish a connection to the database only when it's needed for the first time?
Furthermore, if I invoke the following function multiple times, will it create multiple connections in a single pool, or will it create multiple pools?
con <- function() {
pool::dbPool(odbc::odbc(), driver = "Oracle Instant Client", dbq = "xxx", uid = "xxx", pwd = "xxx")
}
What would be the best approach in this scenario, or is there an example package that addresses this?
For instance, if I need to implement a connection pool within a package, how should I proceed?
Previously, I created
pool::dbPool()in the.onLoad()function and closed it withreg.finalizer(), which worked well. However, adding more data sources would clutter the.onLoad()function. Also, how can I establish a connection to the database only when it's needed for the first time?Furthermore, if I invoke the following function multiple times, will it create multiple connections in a single pool, or will it create multiple pools?
What would be the best approach in this scenario, or is there an example package that addresses this?