diff --git a/plugins/sqlite/handle.js b/plugins/sqlite/handle.js index 670aef2f2..f1b502047 100644 --- a/plugins/sqlite/handle.js +++ b/plugins/sqlite/handle.js @@ -50,6 +50,7 @@ if(mode === 'realtime' || mode === 'importer') { } var db = new sqlite3.Database(fullPath); -db.run('PRAGMA journal_mode = ' + config.sqlite.journalMode||'WAL'); +db.run("PRAGMA journal_mode = WAL"); +db.configure('busyTimeout', 1500); module.exports = db; diff --git a/plugins/sqlite/writer.js b/plugins/sqlite/writer.js index aeade0ea3..08de137f1 100644 --- a/plugins/sqlite/writer.js +++ b/plugins/sqlite/writer.js @@ -3,6 +3,8 @@ var config = require('../../core/util.js').getConfig(); var handle = require('./handle'); var sqliteUtil = require('./util'); +var util = require('../../core/util'); +var log = require('../../core/log'); var Store = function(done, pluginMeta) { _.bindAll(this); @@ -52,7 +54,12 @@ Store.prototype.writeCandles = function() { var stmt = this.db.prepare(` INSERT OR IGNORE INTO ${sqliteUtil.table('candles')} VALUES (?,?,?,?,?,?,?,?,?) - `); + `, function(err, rows) { + if(err) { + log.error(err); + return util.die('DB error at INSERT: '+ err); + } + }); _.each(this.cache, candle => { stmt.run(