File: transactions.Rd

package info (click to toggle)
rmysql 0.10.16-1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 416 kB
  • sloc: ansic: 1,662; sh: 58; makefile: 5
file content (45 lines) | stat: -rw-r--r-- 1,107 bytes parent folder | download
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
% Generated by roxygen2 (4.1.1): do not edit by hand
% Please edit documentation in R/transaction.R
\docType{methods}
\name{transactions}
\alias{dbBegin,MySQLConnection-method}
\alias{dbCommit,MySQLConnection-method}
\alias{dbRollback,MySQLConnection-method}
\alias{transactions}
\title{DBMS Transaction Management}
\usage{
\S4method{dbCommit}{MySQLConnection}(conn, ...)

\S4method{dbBegin}{MySQLConnection}(conn, ...)

\S4method{dbRollback}{MySQLConnection}(conn, ...)
}
\arguments{
\item{conn}{a \code{MySQLConnection} object, as produced by
\code{\link{dbConnect}}.}

\item{...}{Unused.}
}
\description{
Commits or roll backs the current transaction in an MySQL connection.
Note that in MySQL DDL statements (e.g. \code{CREATE TABLE}) can not
be rolled back.
}
\examples{
if (mysqlHasDefault()) {
con <- dbConnect(RMySQL::MySQL(), dbname = "test")
df <- data.frame(id = 1:5)

dbWriteTable(con, "df", df)
dbBegin(con)
dbGetQuery(con, "UPDATE df SET id = id * 10")
dbGetQuery(con, "SELECT id FROM df")
dbRollback(con)

dbGetQuery(con, "SELECT id FROM df")

dbRemoveTable(con, "df")
dbDisconnect(con)
}
}