0
我正在使用sequelezer
將值插入到本地數據庫中。這種安裝腳本需要在服務器上首次運行。用於在SQLite中插入數據值的同步循環
由於的NodeJS「異步」函數調用,我的sqlite的分貝越來越鎖,我收到以下錯誤 Unhandled rejection SequelizeTimeoutError: SQLITE_BUSY: database is locked
這裏我的代碼,
var country_json = {
"AF": "Afghanistan",
"AX": "\u00c5land Islands",
"AL": "Albania",
//........
"ZW": "Zimbabwe"
};
for (key in country_json) {
console.log("ABUZAR");
console.log(key.toString('utf8') + " " + country_json[key].toString('utf8'));
db.country_name.findOrCreate({
where: {
country_iso: key.toString('utf8')
},
defaults: {
country_name: country_json[key].toString('utf8')
}
})
.spread(function(country, created) {
console.log(country.get({
plain: true
}));
console.log(created);
});
}
我試過幾個同步NPM模塊,但他們每個人似乎都在鍛鍊。只是想知道如何在節點js中處理這些場景。