register.connections: Define DB connection settings at run time.

Description Usage Arguments See Also

Description

This function lets users define DB connection settings from sources other than the database.yml config. This is useful for DB setups where a master node maintains a dynamic list of DB nodes. This function only lets you define the connection settings. The actual connection will be open by a subsequent db('my-custom-con1', 'select 1') call. This function doesn't check or validate the input, the caller is responsible for making sure that the list has the correct format, otherwise the connection (i.e. the db call) would fail.

Usage

1
register.connections(db.config, strict = TRUE)

Arguments

db.config

is a list of format:

list(
  my-custom-con1=list(
    database='db1',
    username='analytics',
    password='',
    host='db-1',
    port=5432,
    application_name='rport'
  ),
  my-custom-con2=list(
    database='db2',
    username='analytics',
    password='',
    host='db-2',
    port=5432,
    application_name='rport'
  )
)

Note, that if a list with multiple definitions for the same connection name is given, there'll be an error.

strict

default TRUE. If strict is TRUE, no connection definitions cannot be overwritten and if you try to add a connection name that already exists - either from an earlier register.connections() call or from a database.yml definition, there'll be an error. If strict is FALSE, connections can be overwritten.

See Also

reload.db.config, list.connections


adjust/rport documentation built on May 10, 2019, 5:55 a.m.