Fast and modernized mariadb or mysql connector with zero dependencies and full Temporal support
  • JavaScript 95.3%
  • TypeScript 4.7%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
mariadb-lite e8a9cd29ce
Some checks failed
tests / test (push) Failing after 2m20s
AI: Update AGENT.md with the new Temporal feature
2026-10-15 12:34:06 +00:00
.forgejo/workflows ci: Replace GitHub CI with a Forgejo test workflow 2026-10-15 12:34:06 +00:00
benchmarks temporal: Refactor Date into Temporal 2026-10-15 12:34:06 +00:00
documentation [misc] using tinybench for benchmarking, dropping unsupported benchmark and updating results with recent version 2026-05-21 17:01:45 +02:00
lib temporal: Refactor Date into Temporal 2026-10-15 12:34:06 +00:00
test temporal: Refactor Date into Temporal 2026-10-15 12:34:06 +00:00
tools [misc] auto-generate CommonJS type declarations (types/*.d.cts) from .d.ts 2026-07-22 15:58:15 +02:00
types temporal: Refactor Date into Temporal 2026-10-15 12:34:06 +00:00
.gitattributes [misc] Normalize all the line endings 2021-09-14 14:43:50 +02:00
.gitignore [CONJS-344] Add support for CSJ and ESM 2026-05-21 16:04:48 +02:00
.prettierrc [misc] code style length change to 120 2021-09-17 17:06:13 +02:00
.travis.yml only run benchmark on the master branch to speed up tests 2025-04-23 15:01:05 +02:00
AGENT.md AI: Update AGENT.md with the new Temporal feature 2026-10-15 12:34:06 +00:00
callback.js [misc] fix SqlError losing its constructor shape via namespace import 2026-07-31 12:40:57 +09:00
CHANGELOG.md bump 3.5.4 version 2026-07-30 19:11:16 +02:00
check-node.js [CONJS-326] migrate from commonJS to ESM 2025-08-01 17:45:51 +02:00
codecov.yml [misc] adding codecov configuration 2022-08-19 12:21:01 +02:00
CONTRIBUTING.md [misc] improve contribution guide 2023-01-10 18:23:55 +01:00
deno.json base: Drop runtime dependencies 2026-10-15 12:34:06 +00:00
eslint.config.js [CONJS-357] Add JavaScript SAST: CodeQL workflow + eslint-plugin-security with CI lint gate 2026-07-08 18:39:39 +02:00
FORK.md base: Drop runtime dependencies 2026-10-15 12:34:06 +00:00
LICENSE [misc] adding LGPL2.1+ license file 2018-12-12 20:33:53 +01:00
package.json base: Drop runtime dependencies 2026-10-15 12:34:06 +00:00
promise.js [misc] fix SqlError losing its constructor shape via namespace import 2026-07-31 12:40:57 +09:00
README.md [misc] using tinybench for benchmarking, dropping unsupported benchmark and updating results with recent version 2026-05-21 17:01:45 +02:00

MariaDB Node.js connector

npm package CI Tests License (LGPL version 2.1) codecov

Non-blocking MariaDB and MySQL client for Node.js.

MariaDB and MySQL client, 100% JavaScript, with TypeScript definition, with the Promise API, distributed under the LGPL license version 2.1 or later (LGPL-2.1-or-later)

Since 3.5.3, this requires Node.js 20 or later.

Documentation

See promise documentation for a detailed API.

Callback documentation describes the callback wrapper for compatibility with existing drivers.

See dedicated part for migration from mysql/mysql2 or from the 2.x version.

Why a specific MariaDB Client?

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, Pipelining, ed25519 plugin authentication while making no compromises on performance.

The Connector is production grade quality, with multiple features:

  • zero configuration ssl
  • superfast batching
  • fast pool
  • easy debugging, trace pointing to code line on error
  • allows data streaming without high memory consumption
  • pipelining
  • metadata skipping (for MariaDB server only)
  • sql file import
  • ...

see some of those features:

Insert Streaming

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]);
    });

Pipelining

With Pipelining, the Connector sends commands without waiting for server results, preserving order. For instance, consider the use of executing two INSERT statements.

pipelining example

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.

Bulk insert

Some use cases require a large amount of data to be inserted into a database table. By using batch processing, these queries can be sent to the database in one call, thus improving performance.

For more information, see the Batch documentation.

Benchmarks

MariaDB provides benchmarks comparing the Connector with other Node.js MariaDB/MySQL clients, including mysql (via promise-mysql) and mysql2.

See the Benchmarks page for the full list of results and how to run them.

query

select 100 int
          mariadb : 10,266.8 ops/s ± 0.2%  (  +87.6% )
            mysql :  5,472.4 ops/s ± 0.2%
           mysql2 :  4,783.5 ops/s ± 0.3%  (  -12.6% )

select 100 int benchmark results

execute

select 100 int - BINARY
          mariadb : 10,605.8 ops/s ± 0.2%  ( +124.1% )
           mysql2 :  4,731.8 ops/s ± 0.3%

select 100 int - BINARY benchmark results

Quick Start

The MariaDB Connector is available through the Node.js repositories. You can install it using npm :

$ npm install mariadb

example:

const mariadb = require('mariadb');
const pool = mariadb.createPool({host: process.env.DB_HOST, user: process.env.DB_USER, connectionLimit: 5});

async function asyncFunction() {
  let conn;
  try {

	conn = await pool.getConnection();
	const rows = await conn.query("SELECT 1 as val");
	// rows: [ {val: 1}, meta: ... ]

	const res = await conn.query("INSERT INTO myTable value (?, ?)", [1, "mariadb"]);
	// res: { affectedRows: 1, insertId: 1, warningStatus: 0 }

  } finally {
	if (conn) conn.release(); //release to pool
  }
}

Contributors

A big thanks to all contributors

contributors list

Contributing

If you would like to contribute to the MariaDB Node.js Connector, please follow the instructions given in the contributing guide.

To file an issue or follow the development, see JIRA.