1
在R中,我使用以下函數,該函數在該函數中使用3或4個數據庫操作。但是,錯誤消息顯示如下:數據庫被鎖在R
Error in sqliteExecStatement(conn, statement, ...) :
RS-DBI driver: (RS_SQLite_exec: could not execute1: database is locked)
我需要在我的代碼中做什麼修改?我的代碼如下:
library('RSQLite')
test <- function(portfolio,date,frame){
lite <- dbDriver("SQLite", max.con = 25)
db <- dbConnect(lite, dbname = "portfolioInfo1.db")
sql <- paste("SELECT * from ", portfolio," where portDate='", date, "' ", sep = "")
res <- dbSendQuery(db, sql)
data <- fetch(res)
frame1 <- data.frame(portDate=date,frame)
lite <- dbDriver("SQLite", max.con = 25)
db <- dbConnect(lite, dbname = "portfolioInfo1.db")
sql <- paste("delete from ", portfolio," where portDate='", date, "' ", sep = "")
res <- dbSendQuery(db, sql)
lite <- dbDriver("SQLite", max.con = 25)
db <- dbConnect(lite, dbname = "portfolioInfo1.db")
dbWriteTable(db,portfolio,frame1,append=TRUE,row.names=FALSE)
}
tick <- c("AAPL","TH","YHOO")
quant <- c("121","1313","131313131")
frame <-data.frame(ticker=tick,quantities=quant)
#print(frame)
test("RUSEG","2006-02-28",frame)