我正在做一个无限循环以不断从数据库db收集数据,对其进行返工并将其发送到另一个数据库db1
library(DBI)
library(RSQLite)
while(1==1){
db = dbConnect(SQLite(), dbname="Data.sqlite",synchronous = NULL)
db1 = dbConnect(SQLite(), dbname="Data2.sqlite",synchronous = NULL)
db1
db
Column1=dbGetQuery(db,'select * from Table1')
#Here is some calculations#
Result = Column1/10
#Here calculations are finished and ready to be sent to new database#
dbWriteTable(db1, name="Result", value=Result, row.names=TRUE, append=TRUE)
dbDisconnect(db1)
dbDisconnect(db)
}
当我运行代码时,它执行了大约 10 个循环,然后出现以下错误:rsqlite_send_query(conn@ptr, statement) 中的错误:数据库已锁定
有人可以帮我解决这个问题吗
我通过从 sqlitebrowser 打开数据库并在那里键入以下查询来解决问题:
pragma journal_mode=wal;
了解更多信息:https ://www.sqlite.org/wal.html