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中处理这些场景。