File: dbConnect-MySQLDriver-method.Rd

package info (click to toggle)
rmysql 0.11.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 420 kB
  • sloc: ansic: 1,666; makefile: 5; sh: 1
file content (85 lines) | stat: -rw-r--r-- 2,722 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/connection.R
\name{dbConnect,MySQLDriver-method}
\alias{dbConnect,MySQLDriver-method}
\alias{dbConnect,MySQLConnection-method}
\alias{dbDisconnect,MySQLConnection-method}
\title{Connect/disconnect to a MySQL DBMS}
\usage{
\S4method{dbConnect}{MySQLDriver}(
  drv,
  dbname = NULL,
  username = NULL,
  password = NULL,
  host = NULL,
  unix.socket = NULL,
  port = 0,
  client.flag = 0,
  groups = "rs-dbi",
  default.file = NULL,
  ...
)

\S4method{dbConnect}{MySQLConnection}(drv, ...)

\S4method{dbDisconnect}{MySQLConnection}(conn, ...)
}
\arguments{
\item{drv}{an object of class \code{MySQLDriver}, or the character string
"MySQL" or an \code{MySQLConnection}.}

\item{dbname}{string with the database name or NULL. If not NULL, the
connection sets the default daabase to this value.}

\item{username, password}{Username and password. If username omitted,
defaults to the current user. If password is ommitted, only users
without a password can log in.}

\item{host}{string identifying the host machine running the MySQL server or
NULL. If NULL or the string \code{"localhost"}, a connection to the local
host is assumed.}

\item{unix.socket}{(optional) string of the unix socket or named pipe.}

\item{port}{(optional) integer of the TCP/IP default port.}

\item{client.flag}{(optional) integer setting various MySQL client flags. See
the MySQL manual for details.}

\item{groups}{string identifying a section in the \code{default.file} to use
for setting authentication parameters (see \code{\link{MySQL}}).}

\item{default.file}{string of the filename with MySQL client options.
Defaults to \code{\$HOME/.my.cnf}}

\item{...}{Unused, needed for compatibility with generic.}

\item{conn}{an \code{MySQLConnection} object as produced by \code{dbConnect}.}
}
\description{
These methods are straight-forward implementations of the corresponding
generic functions.
}
\examples{
\dontrun{
# Connect to a MySQL database running locally
con <- dbConnect(RMySQL::MySQL(), dbname = "mydb")
# Connect to a remote database with username and password
con <- dbConnect(RMySQL::MySQL(), host = "mydb.mycompany.com",
  user = "abc", password = "def")
# But instead of supplying the username and password in code, it's usually
# better to set up a group in your .my.cnf (usually located in your home
directory). Then it's less likely you'll inadvertently share them.
con <- dbConnect(RMySQL::MySQL(), group = "test")

# Always cleanup by disconnecting the database
dbDisconnect(con)
}

# All examples use the rs-dbi group by default.
if (mysqlHasDefault()) {
  con <- dbConnect(RMySQL::MySQL(), dbname = "test")
  summary(con)
  dbDisconnect(con)
}
}