db_connection: db_connection helper function

Description Usage Arguments Value See Also Examples

View source: R/db_connection.R

Description

Internal function to test and get the database connection of the target data system.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
db_connection(
  db_name,
  db_type,
  headless = FALSE,
  from_env = TRUE,
  settings = NULL,
  timeout = 30,
  logfile_dir = NULL,
  lib_path = NULL
)

Arguments

db_name

A character. Name of the database system.

db_type

A character. Type of the database system. Currently implemented systems are: 'postgres', 'oracle'.

headless

A boolean (default: FALSE). Indicating, if the function is run only in the console (headless = TRUE) or on a GUI frontend (headless = FALSE).

from_env

A boolean (default: TRUE). Should database connection be read from the environment or from a settings file.

settings

A list. Required if 'from_env=TRUE'. A list containing settings for the database connection. Required fields are 'host', 'db_name', 'port', 'user' and 'password'. Additionally for Oracle DB's: 'sid'.

timeout

A timeout in sec. for the db-connection establishment. Values below 2 seconds are not recommended. Default is 30 seconds.

logfile_dir

(Optional, String, default: "tempdir()") The absolute path to folder where the logfile will be stored.

lib_path

A character string. The path to the ojdbc*.jar file.

Value

If successful, the result will be the established connection. Otherwise the result will be null.

See Also

dbConnect, RPostgres

Examples

1
2
3
4
5
6
7
8
## Not run: 
db_con <- DIZutils::db_connection(
  db_name = "i2b2",
  db_type = "postgres",
  headless = TRUE,
  logfile_dir = tempdir()
)
## End(Not run)

miracum/misc-dizutils documentation built on Nov. 21, 2020, 7:41 p.m.