Skip to content

[Feature]: Use {pool} for DB connections #203

@teofiln

Description

@teofiln

Guidelines

  • I agree to follow this project's Contributing Guidelines.

Description

Curious if using pool to establish DB connections would be possible? Just to be a bit more economical with DB connections.

Not sure if all implemented DB backends are supported by pool, but the SQL ones should be covered

Problem

In my setup, I don't have a dedicated telemetry database, rather the telemetry data are stored in the same DB as the user data. So, the logging would "compete" with users for DB connections.

Proposed Solution

The private method connect could be reworked to use pool::dbPool.

from:

    # Private methods
    connect = function(user, password, hostname, port, dbname, driver) {
      # Initialize connection with database
      private$db_con <- odbc::dbConnect(
        driver,
        user = user,
        password = password,
        dbname = dbname,
        host = hostname,
        port = port
      )
    }

to:

    # Private methods
    connect = function(user, password, hostname, port, dbname, driver) {
      # Initialize connection with database
      private$db_con <- pool::dbPool(
        driver,
        user = user,
        password = password,
        dbname = dbname,
        host = hostname,
        port = port
      )
    }

Alternatives Considered

None that I know of.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions