Skip to content

What's the best practice when using pool in a package? #196

Description

@niheaven

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions