
Security News
NVD Concedes Inability to Keep Pace with Surging CVE Disclosures in 2025
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
Non-blocking MariaDB and MySQL client for Node.js.
MariaDB and MySQL client, 100% JavaScript, compatible with Node.js 6+, with the Promise API.
While there are existing MySQL clients that work with MariaDB, (such as the mysql
and mysql2
clients), the MariaDB Node.js Connector offers new functionality, like Insert Streaming and Pipelining while making no compromises on performance.
Using a Readable stream in your application, you can stream INSERT
statements to MariaDB through the Connector.
https.get('https://someContent', readableStream => {
//readableStream implement Readable, driver will stream data to database
connection.query("INSERT INTO myTable VALUE (?)", [readableStream]);
});
With Pipelining, the Connector sends commands without waiting for server results, preserving order. For instance, consider the use of executing two INSERT
statements.
The Connector doesn't wait for query results before sending the next INSERT
statement. Instead, it sends queries one after the other, avoiding much of the network latency.
For more information, see the Pipelining documentation.
MariaDB provides benchmarks comparing the Connector with popular Node.js MySQL clients, including:
promise-mysql
version 3.3.1 + mysql
version 2.15.0mysql2
version 1.5.3promise-mysql : 1,366 ops/sec ±1.42%
mysql2 : 1,469 ops/sec ±1.63%
mariadb : 1,802 ops/sec ±1.19%
For more information, see the Benchmarks page.
The MariaDB Connector is available through the Node.js repositories. You can install it using npm :
$ npm install mariadb
Using ECMAScript < 2017:
const mariadb = require('mariadb');
const pool = mariadb.createPool({host: 'mydb.com', user:' myUser', connectionLimit: 5});
pool.getConnection()
.then(conn => {
conn.query("SELECT 1 as val")
.then((rows) => {
console.log(rows); //[ {val: 1}, meta: ... ]
return conn.query("INSERT INTO myTable value (?, ?)", [1, "mariadb"]);
})
.then((res) => {
console.log(res); // { affectedRows: 1, insertId: 1, warningStatus: 0 }
conn.end();
})
.catch(err => {
//handle error
conn.end();
})
}).catch(err => {
//not connected
});
Using ECMAScript 2017:
const mariadb = require('mariadb');
const pool = mariadb.createPool({host: 'mydb.com', user: 'myUser', connectionLimit: 5});
async function asyncFunction() {
let conn;
try {
conn = await pool.getConnection();
const rows = await conn.query("SELECT 1 as val");
console.log(rows); //[ {val: 1}, meta: ... ]
const res = await conn.query("INSERT INTO myTable value (?, ?)", [1, "mariadb"]);
console.log(res); // { affectedRows: 1, insertId: 1, warningStatus: 0 }
} catch (err) {
throw err;
} finally {
if (conn) return conn.end();
}
}
The MariaDB Node.js Connector can use different APIs on the back-end: Promise and Callback.
The default API is Promise API.
Callback API is provided for compatibility with the mysql
and mysql2
APIs.
The Connector remains in development. Here's a list of features being developed for future releases:
PoolCluster
ed25519
plugin authenticationIf you would like to contribute to the MariaDB Node.js Connector, please follow the instructions given in the Developers Guide.
To file an issue or follow the development, see JIRA.
2.0.0-alpha - 20 Sep. 2018
FAQs
fast mariadb or mysql connector.
The npm package mariadb receives a total of 98,510 weekly downloads. As such, mariadb popularity was classified as popular.
We found that mariadb demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
Security Fundamentals
Attackers use obfuscation to hide malware in open source packages. Learn how to spot these techniques across npm, PyPI, Maven, and more.
Security News
Join Socket for exclusive networking events, rooftop gatherings, and one-on-one meetings during BSidesSF and RSA 2025 in San Francisco.