[bug] hopefully fix SQLITE_BUSY

This commit is contained in:
Andrea 2022-01-21 10:52:25 +01:00
parent 1f91f09a48
commit dfc5f4ed8f
1 changed files with 9 additions and 4 deletions

View File

@ -39,17 +39,22 @@ class LazyDatabase {
this.db = null;
}
async get(...args) {
async init() {
if (this.db === null) {
this.db = await dbConnection();
await this.db.get('PRAGMA journal_mode = WAL;');
await this.db.get('PRAGMA busy_timeout = 5000;');
await this.db.get('PRAGMA foreign_keys = ON;')
}
}
async get(...args) {
await this.init();
return this.db.get(...args)
}
async all(...args) {
if (this.db === null) {
this.db = await dbConnection();
}
await this.init();
return this.db.all(...args);
}