dbCanConnect: Check if a connection to a DBMS can be established

Description Usage Arguments Value See Also Examples

Description

Like dbConnect(), but only checks validity without actually returning a connection object. The default implementation opens a connection and disconnects on success, but individual backends might implement a lighter-weight check.

\Sexpr[results=rd,stage=render]{DBI:::methods_as_rd("dbCanConnect")}

Usage

1

Arguments

drv

an object that inherits from DBIDriver, or an existing DBIConnection object (in order to clone an existing connection).

...

authentication arguments needed by the DBMS instance; these typically include user, password, host, port, dbname, etc. For details see the appropriate DBIDriver.

Value

A scalar logical. If FALSE, the "reason" attribute indicates a reason for failure.

See Also

Other DBIDriver generics: DBIDriver-class, dbConnect, dbDataType, dbDriver, dbGetInfo, dbIsReadOnly, dbIsValid, dbListConnections

Examples

1
2
3
4
# SQLite only needs a path to the database. (Here, ":memory:" is a special
# path that creates an in-memory database.) Other database drivers
# will require more details (like user, password, host, port, etc.)
dbCanConnect(RSQLite::SQLite(), ":memory:")

Example output

[1] TRUE

DBI documentation built on May 2, 2018, 5:04 p.m.