Progress Bar on Sqlite transaction


#1

Hi guys!
I got a SOAP service for my app that returns a json string with all the query to run to update my local SQLite database.
The list is about 500 queries
I was wandering if i can get the percentage of executed query to set a progress bar (electron native, or the one from bootstrap)

thank you in advance


#2

Can you get some form of mathematical percentage of what you’ve processed?


#3

that’s the question! :smiley:
i don’t know how to get the whole size of the text and the query written…


#4

And how can we know that without piece of code?


#5

here’s the function that i use…

function SyncChat(url, args) {
  return new Promise((resolve,reject)=>{
    var specialRequest = request.defaults({
      strictSSL: false
    });
    var splittedQuery = [];
    var count;
    soap.createClient(url, {
      wsdl_headers: {
        Authorization: secureAuth
      },
      request: specialRequest
    }, function(err, client) {
      //console.log("LOG FROM SOAP ",err,client);
      client.setSecurity(new soap.BasicAuthSecurity(secureUser, securePwd));
      client.SyncChat(args, function(err, result) {
        //console.log("RISULTATI CHAT",args, result);
        var fn = "analytics.db";
        //console.log("SYNC TO DB", js);
        try {

   js =JSON.parse(result.SyncChatResult);
   if (js.length > 0 && js[0].OP != '') {
   var sqliteUpdate = '';
     ob = js[0].OP;
            for (i = 0; i < ob.length; i++) {
              sqliteUpdate += ob[i];
            }
        
        var ana = new sqlite3.Database(path.join(dataPath, fn));
        
        ana.serialize(function() {
          console.log(moment().format("YYYY-MM-DD HH:mm:ss"),"INIZIAMO LA TRANSACTION");
          ana.run("BEGIN TRANSACTION;");
          ob = js[0].OP;
          console.log("DA INSERIRE IN CHAT ",ob.length);
          for (i = 0; i < ob.length; i++) {
            //sqliteUpdate += ob[i];
            ana.exec(ob[i],function (err) {
              if (err) {
                console.log("ERRORE TRANSACTION CHAT ",err);
                ana.run("ROLLBACK;")
                reject(err);
              }
            })
          }
          ana.run("COMMIT;")
          ana.close();
          resolve(true);
          console.log(moment().format("YYYY-MM-DD HH:mm:ss"),"FINE TRANSACTION");

        })
       
      } else {
        resolve(true)
      }
    } catch (e) {
     //console.log("errore ", e);
     reject(e)
    }
  })

})
  })
}