mariadb-corporation / mariadb-connector-nodejs

MariaDB Connector/Node.js is used to connect applications developed on Node.js to MariaDB and MySQL databases. MariaDB Connector/Node.js is LGPL licensed.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Big Array Batch Not Support

hajgreen opened this issue · comments

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();