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.
# S4 method for class 'MySQLConnection'
dbCommit(conn, ...)
# S4 method for class 'MySQLConnection'
dbBegin(conn, ...)
# S4 method for class 'MySQLConnection'
dbRollback(conn, ...)a MySQLConnection object, as produced by
DBI::dbConnect().
Unused.
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)
}
#> Could not initialise default MySQL database. If MySQL is running
#> check that you have a ~/.my.cnf file that contains a [rs-dbi] section
#> describing how to connect to a test database.