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.
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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.