Big Array Batch Not Support
hajgreen opened this issue · comments
Mohammad Rasabakhsh commented
hi
When I want to enter a large batch in the database, instead of one million numbers, the entered value is one million six hundred and maybe less or more. What should I do to solve this problem?
this code:
const mariadb = require('mariadb');
const pool = mariadb.createPool({
host: "127.0.0.1",
user: "root",
database: "test",
password: "",
// connectionLimit: 5
});
async function batchDataDB(array) {
// Database Insert Data
let conn;
try {
conn = await pool.getConnection();
return await conn.batch("INSERT INTO user (name, code_id, city) VALUES (?, ?, ?);", array);
} catch (err) {
console.log(err);
} finally {
if (conn) return conn.end();
}
}
var arr = [];
for (let i = 0; i < 1_000_000; i++) {
arr.push(["this a name", (i), "this a city"]);
}
async function bdb() {
await batchDataDB(arr);
}
bdb();