-
Notifications
You must be signed in to change notification settings - Fork 101
Open
Description
Given the following environment (Windows 11)
C:\Development\YADAMU\src\scratch\mariadb>node -v
v20.7.0
C:\Development\YADAMU\src\scratch\mariadb>npm ls
[email protected] C:\Development\YADAMU\src
+-- @aws-sdk/[email protected]
+-- @aws-sdk/[email protected]
+-- @azure/[email protected]
+-- @electron/[email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- ibm_db_electron@npm:[email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
+-- [email protected]
`-- [email protected]
And the following code
C:\Development\YADAMU\src\scratch\mariadb>type batchInsert.js
"use strict"
import mariadb from 'mariadb';
import fs from 'fs';
async function main() {
const connectionDetails = {
host : "yadamu-db1"
,user : "root"
,password : "oracle"
,port : 3307
,database : "mysql"
,multipleStatements: true
,typeCast:true
,bigNumberStrings:true
,dateStrings:true
,rowsAsArray:true}
let results;
try {
const pool = mariadb.createPool(connectionDetails);
const conn = await pool.getConnection();
results = await conn.query(`SET AUTOCOMMIT = 0, TIME_ZONE = '+00:00',SESSION INTERACTIVE_TIMEOUT = 600000, WAIT_TIMEOUT = 600000, SQL_MODE='ANSI_QUOTES,PAD_CHAR_TO_FULL_LENGTH', GROUP_CONCAT_MAX_LEN = 1024000, GLOBAL LOCAL_INFILE = 'ON';`);
results = await conn.query(`drop schema if exists "YADAMU_TEST";`);
results = await conn.query(`create schema "YADAMU_TEST";`);
results = await conn.query(`USE "YADAMU_TEST"`);
results = await conn.query(`create table if not exists "YADAMU_TEST"."character_types"(
"character_col" char(1) ,"character_varying_col" longtext ,"character_max_col" mediumtext ,"character_varying_max_col" mediumtext ,"character_4000_col" varchar(4000) ,"character_varying_4000_col" varchar(4000) ,"character_64k_col" text ,"character_varying_64k_col" text ,"text_col" longtext)`);
const testData = fs.readFileSync('TEST_DATA.json');
const data = JSON.parse(testData)
console.log('ROWS',data.length)
const sql = `insert into "YADAMU_TEST"."character_types" ("character_col","character_varying_col","character_max_col","character_varying_max_col","character_4000_col","character_varying_4000_col","character_64k_col","character_varying_64k_col","text_col") values (?,?,?,?,?,?,?,?,?)`;
try {
results = await conn.beginTransaction()
results = await conn.query(`SAVEPOINT YADAMU_INSERT; `)
console.log('Insert')
results = await conn.batch(sql,data);
console.log('Commit')
results = await conn.commit()
console.log('Success')
} catch (e) {
console.log('Failed')
console.log(e)
}
conn.end()
pool.end();
} catch(e) {
console.log(e);
}
}
main().then(() => {console.log("Complete")}).catch((e) => {console.log(e)})
The batch insert operation hangs
C:\Development\YADAMU\src\scratch\mariadb>node batchInsert.js
ROWS 4
Insert
^C
C:\Development\YADAMU\src\scratch\mariadb>
Metadata
Metadata
Assignees
Labels
No labels