Learn R Programming

RMySQL (version 0.10.2)

transactions: DBMS Transaction Management

Description

Commits or roll backs the current transaction in an MySQL connection. Note that in MySQL DDL statements (e.g. CREATE TABLE) can not be rolled back.

Usage

## S3 method for class 'MySQLConnection':
dbCommit(conn, ...)

## S3 method for class 'MySQLConnection': dbBegin(conn, ...)

## S3 method for class 'MySQLConnection': dbRollback(conn, ...)

Arguments

conn
a MySQLConnection object, as produced by dbConnect.
...
Unused.

Examples

Run this code
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)
}

Run the code above in your browser using DataLab