How to check if a "Send Query" is over?

Viewed 119

I need to check if my res from dbSendQuery() is over.

My code is like this:

db <- dbConnect(drv=SQLite(),flags=SQLITE_RW,dbname="db.sqlite",synchronous = "off")
dbBegin(db)
res <- dbSendQuery(db,"Update Operation SET Name = 'teste' where Id = 1")
if("my SendQuery is over"){
  dbClearResult(res)
  dbCommit(db)
  dbDisconnect(db)
}

I need to know when it is over to send this to commit and then disconnect.

UPDATE 1 Im my sistem, for this example above can happen with more than 1 users simultaneous. Then, when the first connection in db is over, i need to finish him requisition and provide to the other connection the possibility to write your query.

1 Answers

dbSendQuery() always awaits completion. You can double-check by calling dbGetRowsAffected(res) .

For SQL statements that are run for the side effect and do not return a value, dbSendStatement() is preferred.

The synchronous = "off" argument to dbConnect() is a misnomer, this defines when and how the data is written to disk; no multi-threading is involved here.

Related