sqlite3.datebase.serialize(function(){})的问题

如果内部的查询函数有回调函数,还是不能同步执行的。。。。

所以大概只能执行更新、删除、新建之类的任务了。。。。

官方文档地址

db.serialize(function() {
  // These two queries will run sequentially.(同步进行、序列化、按顺序执行)
  console.log(client.collector1);
  console.log('\n11111111111111:');
  db.all(" select eqpt_pfc from eqpt_info where eqpt_id_code='" + client.collector1 +"'" , function(err, rows){
    console.log('\n1:');
    console.log(rows[0]);
    PFC = rows[0].eqpt_pfc;
    console.log(PFC);
  });
  db.all(" select eqpt_baudrate , eqpt_commport , eqpt_measurecode , eqpt_rate , eqpt_zsw , eqpt_xsw , eqpt_dlh , eqpt_xlh , eqpt_yblx from eqpt_info where eqpt_id_code = '" + address +"'", function(err, rows) {
    console.log('\n2:');
    console.log(rows[0]);
  });
});

 最后还是要做嵌套查询。。。

posted @ 2015-10-23 10:16  流殇微  阅读(537)  评论(0编辑  收藏  举报