node.js - How to use batch insert in node jdbc module with teradata -


i trying insert huge data teradata database node.js application. have array of insert statement. need insert them batch. please help.

note: looking below used in java program

statement.addbatch(query); statement.executebatch(); 

but couldn't find in jdbc npm module.

i had similar need , looked @ jdbc , nodejdbc packages, , neither offered support jdbc's batch update methods. ended-up adding them promise-based nodejdbc package , submitted pull request changes.

update nodejdbc maintainer accepted pr, , batch support part of package!

example (es6 used):

thedb.getconnection().then(conn => {   return conn.preparestatement('insert test values (?,?)') }).then(pstmt => {   (let i=0; i<10; i++) {     pstmt.setint(1, i);     pstmt.setstring(2, `num${i}`);     pstmt.addbatchsync();   }   return pstmt.executebatch(); }).then(rowsupdated => {   console.log('rows update:', rowsupdated); }).catch(error => console.error('error occurred during batch insert', error)); 

Comments

Popular posts from this blog

Hatching array of circles in AutoCAD using c# -

ios - UITEXTFIELD InputView Uipicker not working in swift -