transactions
From RMySQL v0.10.20
by Jeroen Ooms
DBMS Transaction Management
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
# S4 method for MySQLConnection
dbCommit(conn, ...)# S4 method for MySQLConnection
dbBegin(conn, ...)
# S4 method for MySQLConnection
dbRollback(conn, ...)
Arguments
- conn
a
MySQLConnection
object, as produced bydbConnect
.- ...
Unused.
Examples
# NOT RUN {
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)
}
# }
Community examples
Looks like there are no examples yet.