redhat_db_conn: Connect to a database in R

Description Usage Arguments Details Value

Description

Establish a connection to a JDBC or PostgreSQL database, and return that value in order to query the database.

Usage

1
redhat_db_conn(filename, instance, env.passname)

Arguments

filename

the location of the database config file. Should contain the scheme, host, port, database (if applicable), classname, jars, and user. Password will be prompted.

instance

if the config file has multiple instances in it (e.g. production and development), specific which instance to connect to.

env.passname

the name of the environment variable that is storing the obscured password. Create this using set_env_pass

Details

This function requires the user to have access to the database, have downloaded the driver, and set up the certificates on their computer. The process for using the package is to create a config file, then pass it along with the path:

vdm.conn <- redhat_db_conn("~/.vdm.cfg")

sales.conn <- redhat_db_conn("~/.sales.cfg")

Then, the created connection can be used with the DBI package:

DBI::dbGetQuery(vdm.conn, "SELECT id FROM APL_CEE_VDM.stg_gss_case LIMIT 10")

DBI::dbGetQuery(sales.conn, "SELECT unique_identifier FROM rsds_ops_clv.customer_timeline_oracle_18q1 WHERE unique_identifier != '' LIMIT 10")

Value

redhat_db_conn returns a database connection that can be used for SQL queries


brascoball/hattyr documentation built on May 13, 2019, 2:30 a.m.