如何解决发出POST请求时,SQLite3数据库被锁定
我向我的SQLite3数据库(ruby on rails API)发出了两次发布请求,我得到的是一个锁定的数据库:(
您能帮我吗?
addRecord() {
const value = this.newRecord;
if (!value) {
return;
}
this.$http.secured --------------------------------------------------->THIS ONE
.post("/api/v1/records/",{
record: {
description: this.newRecord.description,time: this.newRecord.time,path: this.selected.key,effect: this.selectedEff.key,template_id: this.newRecord.template
}
})
.then(response => {
this.records.push(response.data);
this.newRecord.description = "";
this.newRecord.time = "";
this.selected = "";
this.selectedEff = "";
this.newRecord.template = "";
this.$toasted.success("RECORD ADDED SUCCESSFULLY!",{
position: "top-center",duration: 3000,theme: "bubble"
});
// this.$router.go();
})
.catch(error =>
this.$toasted.error("ERROR,MAKE SURE EVERYTHING IS FILLED!",theme: "bubble"
})
);
this.$http.secured ----------------------------------------->AND THIS ONE
.post("/api/v1/logs/",{
log: {
action: this.newRecord.description,action_type: "CREATED",element: "RECORD"
}
})
.catch(error =>
this.$toasted.error("COULDNT CREATE LOG!",theme: "bubble"
})
);
},
现在我得到的是 500(内部服务器错误),说 SQLite3 :: BusyException:数据库已锁定
我已经尝试过在此站点上找到的每个答案都没有改变。
我试图像这样设置超时时间: database.yml :
default: &default
adapter: sqlite3
pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %>
timeout: 10000
development:
<<: *default
database: db/development.sqlite3
test:
<<: *default
database: db/test.sqlite3
production:
adapter: sqlite3
database: db/mysite_prod.sqlite3
timeout: 10000
我已经在Rails控制台中尝试了 ActiveRecord::Base.connection.execute("BEGIN TRANSACTION; END;")
命令。似乎什么都没用,您能帮我吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。