Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

DBIConnector-class

DBIConnector class


Description

Wraps objects of the DBIDriver class to include connection options. The purpose of this class is to store both the driver and the connection options. A database connection can be established with a call to dbConnect(), passing only that object without additional arguments.

Details

To prevent leakage of passwords and other credentials, this class supports delayed evaluation. All arguments can optionally be a function (callable without arguments). In such a case, the function is evaluated transparently when connecting in dbGetConnectArgs().

See Also

Other DBIConnector generics: dbConnect(), dbDataType(), dbGetConnectArgs(), dbIsReadOnly()

Examples

# Create a connector:
cnr <- new("DBIConnector",
  .drv = RSQLite::SQLite(),
  .conn_args = list(dbname = ":memory:")
)
cnr

# Establish a connection through this connector:
con <- dbConnect(cnr)
con

# Access the database through this connection:
dbGetQuery(con, "SELECT 1 AS a")
dbDisconnect(con)

DBI

R Database Interface

v1.1.1
LGPL (>= 2.1)
Authors
R Special Interest Group on Databases (R-SIG-DB) [aut], Hadley Wickham [aut], Kirill Müller [aut, cre] (<https://orcid.org/0000-0002-1416-3412>), R Consortium [fnd]
Initial release
2021-01-04

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.