db_connect: Create a connection to a DBMS

Description Usage Arguments Value Examples

View source: R/easydb.R

Description

It's a simple wrapper around DBI::dbConnect that makes it easy to use specs stored in a list and makes it easier to choose the relevant driver.

Usage

1
2
db_connect(drv = c("SQLite", "MariaDB", "MySQL", "Odbc", "Oracle",
  "PostgreSQL"), ...)

Arguments

drv

a character used to match partially a DBMS name (ignoring case) and match it to a default driver, OR DBIDriver object (as with DBI::dbConnect), OR a list of specs (in which case other parameters are ignored)

...

authentication arguments needed by the DBMS instance; supported parameters depend on driver and are enumerated in ?RSQLite::SQLite, ?RMariaDB::MariaDB, RMySQL::MySQL, ?odbc::odbc, ROracle::Oracle, ?RPostgres::Postgres or in the help file of the appropriate driver.

Value

an S4 object that inherits from DBIConnection. This object is used to communicate with the database engine.

Examples

1
2
3
4
5
6
7
8
# using only defaults
db_connect(path=":memory:")
# feeding a list of specs to the drv argument
db_connect(list(path=":memory:"))
# partial matching
db_connect(drv = "sqli", path=":memory:")
# explicit driver
db_connect(drv = RSQLite::SQLite(), path=":memory:")

moodymudskipper/easydb documentation built on Nov. 4, 2019, 7:29 p.m.