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.
GNU Lesser General Public License v2.1
369 stars 91 forks source link

Big Array Batch Not Support #267

Closed hajgreen closed 5 months ago

hajgreen commented 9 months ago

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();
rusher commented 5 months ago

closing since corrected on 3.3.0 version