Create a connection to a DBMS

Connect to a DBMS going through the appropriate authorization procedure. Some implementations may allow you to have multiple connections open, so you may invoke this function repeatedly assigning its output to different objects. The authorization mechanism is left unspecified, so check the documentation of individual drivers for details.

dbConnect(drv, ...)
an object that inherits from DBIDriver, or an existing DBIConnection object (in order to clone an existing connection).
authorization arguments needed by the DBMS instance; these typically include user, password, dbname, host, port, etc. For details see the appropriate DBIDriver.

Each driver will define what other arguments are required, e.g., "dbname" for the database name, "username", and "password".


An object that extends DBIConnection in a database-specific manner. For instance dbConnect(RMySQL::MySQL()) produces an object of class MySQLConnection. This object is used to direct commands to the database engine.

See Also

dbDisconnect to disconnect from a database.

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

  • dbConnect
library(DBI) # SQLite only needs a path to the database. Other database drivers # will require more details (like username, password, host, port etc) con <- dbConnect(RSQLite::SQLite(), ":memory:") con dbListTables(con) dbDisconnect(con)
Documentation reproduced from package DBI, version 0.5-1, License: LGPL (>= 2)

Community examples

Looks like there are no examples yet.