dbConnect {Rdbi} | R Documentation |
dbConnect
is a generic function that, when evoked with a valid
database class, will return a connection object.
dbConnect(dbObj, ...)
dbObj |
A database class object. |
... |
An argument list specifying connection options. |
Each package that sub-classes Rdbi must provide a dbConnect
function. The first argument of the dbConnect
function is an
object whose class determines which dbConnect
method is
actually called. For example, the Rdbi.PgSQL package provides a
function PgSQL()
that returns an object of class
c("PgSQL", "Rdbi")
. Therefore the call
dbConnect(PgSQL(), ...)
will invoke the method
dbConnect.PgSQL
. Rdbi arranges for the specific package
to be loaded via the autoload
mechanism. In this
example, Rdbi.PgSQL is autoloaded when PgSQL
is called.
A database connection object that inherits from "Rdbi.conn". Additionally, the connection object should possess two attributes required to reopen the connection from the object. The "library.call" contains a call or expression that will load the library necessary to support the connection object. The "connect.call" attribute should contain the call that created the connection object. Also, it is very convenient to arrange for low-level connection resources to be freed when the R connection object is garbage collected. See the Rdbi.PgSQL C code for an example.
Timothy H. Keitt
dbDisconnect
, dbReconnect
,
methods, class
, match.call