1

I am using Seriate module in Nodejs for making my Tsql queries. Now I am stuck in implementing bulk insert with it. Seriate documentation dosen't say any thing about bulk inserting.

https://github.com/LeanKit-Labs/seriate

I am trying different things to able to perform that. If it is possible with it please help.

  var accountArray=[];
    accounts.forEach(function(account){
        accountArray.push(
       [account['@url'],
       account['Active'],
       account['Description'],
       account['Number'],
       account['SRU'],
       account['Year']])
    });

    var sqlFile ='./sql/account.bulkInsert.sql';

    sql.execute({
        query: sql.fromFile(sqlFile),
        params:{accountArray:accountArray}


    }).then(function (result) {
            console.log("SUCCESS")
            logger.stream.write((isTemp ? '(temp) ' : '') +
                  'account.bulkInsert resolved.');
            resolve(result);
        })
        .catch(function (err) {
            console.log("Error")
            console.log(err)
            logger.stream.write((isTemp ? '(temp) ' : '') +
                 'account.bulkInsert  rejected.');
            reject(err);
        });

My './sql/account.bulkInsert.sql' file contains this

BULK INSERT INTO [dbo].[Account] (
      [@url]
    , [active]
    , [Description]
    , [Number]
    , [SRU]
    , [Year]
    )
VALUES ?;

Is it possible that my query is wrong or my way of passing data in params via Seriate is wrong.

Note:- I am using sql server.

Chris
  • 6,272
  • 9
  • 35
  • 57
Achilles
  • 519
  • 7
  • 27

1 Answers1

0

I was able to do a standard insert from an array object, using a combination of CSV-parse to pull from a CSV file, transforming the CSV/text file into an array, then piping that out, but I'm not aware of a traditional 'bulk-insert.'

Were you able to make that work with seriate? The 'mssql' module has a bulk insert feature, but I've not known anyone able to make that work effectively.

awilliams
  • 36
  • 7
  • This is really a comment, not an answer. With a bit more rep, [you will be able to post comments](//stackoverflow.com/privileges/comment). – Enamul Hassan Jun 14 '16 at 18:42