---
title: "MariaDB Connector/Node.js First Alpha Now Available"
publish_date: 2018-07-20
updated_date: 2019-08-26
author: "Diego Dupin"
tags:
  - name: "Connector"
    url: "/resources/blog/tag/connector.md"
  - name: "First Alpha"
    url: "/resources/blog/tag/first-alpha.md"
  - name: "MariaDB Connector"
    url: "/resources/blog/tag/mariadb-connector.md"
  - name: "MariaDB Node.js"
    url: "/resources/blog/tag/mariadb-node-js.md"
  - name: "MySQL"
    url: "/resources/blog/tag/mysql.md"
  - name: "mysql2"
    url: "/resources/blog/tag/mysql2.md"
  - name: "Node.js"
    url: "/resources/blog/tag/node-js.md"
  - name: "Pipelining"
    url: "/resources/blog/tag/pipelining.md"
  - name: "Streaming"
    url: "/resources/blog/tag/streaming.md"
  - name: "version 0.7.0"
    url: "/resources/blog/tag/version-0-7-0.md"
---

# MariaDB Connector/Node.js First Alpha Now Available

MariaDB is pleased to announce the immediate availability of [MariaDB Connector/Node.js alpha version 0.7.0](https://staging-mdb.com/kb/en/library/about-mariadb-connector-nodejs/ "MariaDB Server 10.3.8 Release Notes"). This is a non-blocking MariaDB client for Node.js, 100 percent JavaScript, compatible with Node.js 6+.

Why a new client? While there are existing clients that work with MariaDB, (such as the [mysql](https://www.npmjs.com/package/mysql) and [mysql2](https://www.npmjs.com/package/mysql2) clients), the MariaDB Node.js Connector offers new functionality, like insert Streaming and Pipelining while making no compromises on performance.

### Insert Streaming

Using a Readable stream in your application, you can stream `INSERT` statements to MariaDB through the Connector.

```javascript
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.

![pip - Copie.png](https://staging-mdb.com/sites/default/files/users/user15430/pip%20-%20Copie.png)

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.

## Quick Start

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

```
$ npm install mariadb

```

Using ECMAScript 2017:

```javascript
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();
  }
}
```

Documentation can be found on the [MariaDB knowledge base](https://staging-mdb.com/kb/en/library/nodejs-connector/) and sources are on [GitHub](https://github.com/MariaDB/mariadb-connector-nodejs).

## Benchmarks

Comparing the MariaDB Connector with other Node.js clients:

- [`promise-mysql`](https://www.npmjs.com/package/promise-mysql) version 3.3.1 + [`mysql`](https://www.npmjs.com/package/mysql) version 2.15.0
- [`mysql2`](https://www.npmjs.com/package/mysql2) version 1.5.3

```
promise-mysql  : 1,366 ops/sec ±1.42%
mysql2         : 1,469 ops/sec ±1.63%
mariadb        : 1,802 ops/sec ±1.19%

```

![bench.png](https://staging-mdb.com/sites/default/files/users/user15430/bench.png)

Benchmarks for the MariaDB Node.js Connector are done using the popular [benchmark.js](https://www.npmjs.com/package/benchmark) package. You can find the source code for our benchmarks in the [`benchmarks/`](https://github.com/MariaDB/mariadb-connector-nodejs/blob/master/benchmarks) folder.

## Roadmap

The MariaDB Node.js Connector remains in development. This is an alpha release so we do not recommend using it in production. Below is a list of features being developed for future connector releases.

- `PoolCluster`
- MariaDB `ed25519` plugin authentication
- Query Timeouts
- Bulk Insertion, (that is, fast batch).

###### [Download the MariaDB Node.js Connector directly](https://staging-mdb.com/downloads/mariadb-tx/connector).