connectODBC: Connect to ODBC Database Using keyring

Description Usage Arguments Details Value Creation notes Author(s) Examples

View source: R/connectODBC.R

Description

Creates connection to ODBC database using the data contained in keyrings.

Usage

1
connectODBC(databaseString = NULL)

Arguments

databaseString

Same as the service saved in the keyring. Default NULL will list the available keys prefixed with 'DB_'

Details

Keys should be set up prior to using the function to a style similar to:
keyring::key_set("DB_MARC_PRD.marcdl", username = "Driver={ODBC Driver 17 for SQL Server};Server=knights;Database=MARC_PRD;UID=marcdl;PWD=PASSWORD;")
Leave the PWD section in the username argument written as PASSWORD as this is automatically replaced with the stored password when calling connectODBC()

Value

OBDC connection object returned from DBI::dbConnect()

Creation notes

First created in 2020-Sept for easily accessing databases in R

Author(s)

Jacob Peterson

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
## Not run: 
library(glue)
library(magrittr)
library(DBI)

con <- connectODBC("DB_MARC_PRD.marcdl")

glue::glue("
SELECT *
  FROM marcdl.VW_CovidCasesDeathsTestsLastUpdated
") %>%
  DBI::dbGetQuery(con, .)

## End(Not run)

MARC-GIS/marcR documentation built on Nov. 16, 2020, 1:41 p.m.