EVOLUTION-MANAGER
Edit File: dbConnect.html
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><title>R: Create a connection to a DBMS</title> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="stylesheet" type="text/css" href="R.css" /> </head><body> <table width="100%" summary="page for dbConnect {DBI}"><tr><td>dbConnect {DBI}</td><td style="text-align: right;">R Documentation</td></tr></table> <h2>Create a connection to a DBMS</h2> <h3>Description</h3> <p>Connect to a DBMS going through the appropriate authentication 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 authentication mechanism is left unspecified, so check the documentation of individual drivers for details. Use <code><a href="dbCanConnect.html">dbCanConnect()</a></code> to check if a connection can be established. </p> <h3>Usage</h3> <pre> dbConnect(drv, ...) </pre> <h3>Arguments</h3> <table summary="R argblock"> <tr valign="top"><td><code>drv</code></td> <td> <p>an object that inherits from <a href="DBIDriver-class.html">DBIDriver</a>, or an existing <a href="DBIConnection-class.html">DBIConnection</a> object (in order to clone an existing connection).</p> </td></tr> <tr valign="top"><td><code>...</code></td> <td> <p>authentication arguments needed by the DBMS instance; these typically include <code>user</code>, <code>password</code>, <code>host</code>, <code>port</code>, <code>dbname</code>, etc. For details see the appropriate <code>DBIDriver</code>.</p> </td></tr> </table> <h3>Value</h3> <p><code>dbConnect()</code> returns an S4 object that inherits from <a href="DBIConnection-class.html">DBIConnection</a>. This object is used to communicate with the database engine. </p> <p>A <code><a href="../../base/html/format.html">format()</a></code> method is defined for the connection object. It returns a string that consists of a single line of text. </p> <h3>Specification</h3> <p>DBI recommends using the following argument names for authentication parameters, with <code>NULL</code> default: </p> <ul> <li> <p><code>user</code> for the user name (default: current user) </p> </li> <li> <p><code>password</code> for the password </p> </li> <li> <p><code>host</code> for the host name (default: local connection) </p> </li> <li> <p><code>port</code> for the port number (default: local connection) </p> </li> <li> <p><code>dbname</code> for the name of the database on the host, or the database file name </p> </li></ul> <p>The defaults should provide reasonable behavior, in particular a local connection for <code>host = NULL</code>. For some DBMS (e.g., PostgreSQL), this is different to a TCP/IP connection to <code>localhost</code>. </p> <p>In addition, DBI supports the <code>bigint</code> argument that governs how 64-bit integer data is returned. The following values are supported: </p> <ul> <li> <p><code>"integer"</code>: always return as <code>integer</code>, silently overflow </p> </li> <li> <p><code>"numeric"</code>: always return as <code>numeric</code>, silently round </p> </li> <li> <p><code>"character"</code>: always return the decimal representation as <code>character</code> </p> </li> <li> <p><code>"integer64"</code>: return as a data type that can be coerced using <code><a href="../../base/html/integer.html">as.integer()</a></code> (with warning on overflow), <code><a href="../../base/html/numeric.html">as.numeric()</a></code> and <code><a href="../../base/html/character.html">as.character()</a></code> </p> </li></ul> <h3>See Also</h3> <p><code><a href="dbDisconnect.html">dbDisconnect()</a></code> to disconnect from a database. </p> <p>Other DBIDriver generics: <code><a href="DBIDriver-class.html">DBIDriver-class</a></code>, <code><a href="dbCanConnect.html">dbCanConnect</a>()</code>, <code><a href="dbDataType.html">dbDataType</a>()</code>, <code><a href="dbDriver.html">dbDriver</a>()</code>, <code><a href="dbGetInfo.html">dbGetInfo</a>()</code>, <code><a href="dbIsReadOnly.html">dbIsReadOnly</a>()</code>, <code><a href="dbIsValid.html">dbIsValid</a>()</code>, <code><a href="dbListConnections.html">dbListConnections</a>()</code> </p> <p>Other DBIConnector generics: <code><a href="DBIConnector-class.html">DBIConnector-class</a></code>, <code><a href="dbDataType.html">dbDataType</a>()</code>, <code><a href="dbGetConnectArgs.html">dbGetConnectArgs</a>()</code>, <code><a href="dbIsReadOnly.html">dbIsReadOnly</a>()</code> </p> <h3>Examples</h3> <pre> # 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.) con <- dbConnect(RSQLite::SQLite(), ":memory:") con dbListTables(con) dbDisconnect(con) </pre> <hr /><div style="text-align: center;">[Package <em>DBI</em> version 1.1.0 <a href="00Index.html">Index</a>]</div> </body></html>