dbCommit-methods

0th

Percentile

DBMS Transaction Management

By default, SQLite is in auto-commit mode. dbBeginTransaction starts a SQLite transaction and turns auto-commit off. dbCommit and dbRollback commit and rollback the transaction, respectively and turn auto-commit on.

Keywords
methods, interface, database
References

See the Database Interface definition document DBI.pdf in the base directory of this package or http://stat.bell-labs.com/RS-DBI.

See Also

SQLite, dbConnect, dbSendQuery, dbGetQuery, fetch, dbCommit, dbGetInfo, dbReadTable.

Aliases
  • dbBeginTransaction
  • dbBeginTransaction-methods
  • dbCommit-methods
  • dbRollback-methods
  • dbBeginTransaction,SQLiteConnection-method
  • dbCommit,SQLiteConnection-method
  • dbRollback,SQLiteConnection-method
Examples
drv <- dbDriver("SQLite")
tfile <- tempfile()
con <- dbConnect(drv, dbname = tfile)
data(USArrests)
dbWriteTable(con, "arrests", USArrests)
dbGetQuery(con, "select count(*) from arrests")[1, ]

dbBeginTransaction(con)
rs <- dbSendQuery(con, "DELETE from arrests WHERE Murder > 1")
dbGetQuery(con, "select count(*) from arrests")[1, ]
if (dbGetInfo(rs)[["rowsAffected"]] > 40)
  dbRollback(con)
dbGetQuery(con, "select count(*) from arrests")[1, ]

dbBeginTransaction(con)
rs <- dbSendQuery(con, "DELETE from arrests WHERE Murder > 5")
dbCommit(con)
dbGetQuery(con, "select count(*) from arrests")[1, ]


dbDisconnect(con)
Documentation reproduced from package RSQLite, version 0.6-4, License: LGPL version 2 or newer

Community examples

Looks like there are no examples yet.