• Stars
    star
    366
  • Rank 116,547 (Top 3 %)
  • Language
    JavaScript
  • License
    GNU Lesser Genera...
  • Created over 6 years ago
  • Updated 2 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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.

MariaDB Node.js connector

npm package Test Build 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.

Documentation

See promise documentation for detailed API.

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

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

Why a New 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.

Connector is production grade quality, with multiple features:

  • 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:

See the Benchmarks page for multiple results.

query

select 100 int
            mysql :  2,738.7 ops/s ± 1.3% 
           mysql2 :  2,404.9 ops/s ± 1.3%  (  -12.2% )
          mariadb :  5,650.8 ops/s ± 1.4%  ( +106.3% )

select 100 int benchmark results

execute

select 100 int - BINARY

select 100 int - BINARY
           mysql2 :  2,473.4 ops/s ± 1.3% 
          mariadb :   10,533 ops/s ± 1.7%  ( +325.9% )

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
  }
}

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.

More Repositories

1

MaxScale

An intelligent database proxy.
C++
1,374
star
2

mariadb-connector-j

MariaDB Connector/J is used to connect applications developed in Java to MariaDB and MySQL databases. MariaDB Connector/J is LGPL licensed.
Java
330
star
3

mariadb-connector-c

MariaDB Connector/C is used to connect applications developed in C/C++ to MariaDB and MySQL databases.The client library is LGPL licensed.
C
277
star
4

mariadb-connector-python

MariaDB Connector/Python
Python
131
star
5

mariadb-connector-r2dbc

Connector for Java R2DBC
Java
114
star
6

mariadb-columnstore-engine

Core storage engine - UM and PM Process code
C++
106
star
7

mariadb-connector-cpp

MariaDB Connector for C++
C++
78
star
8

mariadb-columnstore-server

Modified version of MariaDB for ColumnStore
C++
62
star
9

mariadb-connector-odbc

MariaDB Connector ODBC. A driver which enables ODBC applications to communicate with MariaDB and MySQL servers
C
47
star
10

maxscale-docker

Shell
39
star
11

Developer-Examples

This repository contains samples applications demonstrating the power of MariaDB!
36
star
12

dev-example-todo

JavaScript
20
star
13

mariadb-columnstore-sample-data

Example queries and dataset for use with MariaDB ColumnStore
Shell
19
star
14

mariadb-community-columnstore-docker

Official MariaDB ColumnStore Community Docker Image
Shell
19
star
15

mariadb-qa

MariaDB QA (mariadb-qa)
PLpgSQL
14
star
16

mariadb-columnstore-docker

Shell
11
star
17

mariadb-columnstore-api

C++
11
star
18

libmarias3

A lightweight, LGPL-2.1 licensed C API to read from / write to S3 buckets
C
11
star
19

dev-example-places

A web application (with multiple API project options) that uses MariaDB!
JavaScript
10
star
20

dev-example-bookings

A web application (with multiple API project options) that uses MariaDB HTAP!
JavaScript
9
star
21

dev-example-modern-sql

9
star
22

dev-example-flights

A simple web application demonstrating the power and simplicity of MariaDB ColumnStore.
JavaScript
8
star
23

dev-example-connector-python

A repository that provides samples that use MariaDB Connector/Python
8
star
24

columnstore-ansible-aws

HCL
7
star
25

skysql-api-go

MariaDB SkySQL API Golang SDK
Dockerfile
6
star
26

mdbci

MariaDBCI
Ruby
6
star
27

mariadb-columnstore-data-adapters

Java
5
star
28

mariadb-training

PHP
5
star
29

skysql-api-cli

MariaDB SkySQL API CLI Client
Go
5
star
30

dev-example-orders

A web application (with multiple API project options) that uses MariaDB!
JavaScript
5
star
31

mariadb-enterprise-columnstore-docker

Enterprise MariaDB Columnstore Cluster Project
Shell
5
star
32

dev-example-nosql-listener

This repository contains information on how to create and use a MariaDB MaxScale NoSQL Listener with MariaDB Community Server.
JavaScript
5
star
33

dev-example-columnstore-quickstart

Shell
4
star
34

dev-example-pl-sql

4
star
35

terraform-provider-skysql

MariaDB SkySQL terraform provider
Go
4
star
36

mariadb-columnstore-tools

Shell
4
star
37

xbench-community

Python
3
star
38

dev-example-blog-samples

Python
3
star
39

dev-example-orms

Object-Relational Mapping and MariaDB samples
JavaScript
3
star
40

mariadb-powerbi

Power BI DirectQuery Connector
3
star
41

galera-qa

MariaDB Galera Testing Tool
Yacc
2
star
42

MaxScale-Documentation

MaxScale end-user documentation.
CSS
2
star
43

build-scripts

Shell
2
star
44

xpand-locust

Python
1
star
45

dev-example-r2dbc-sample

Java
1
star
46

dev-example-skysql-htap-quickstart

Shell
1
star
47

dev-example-htap-community

Shell
1
star
48

dev-example-microservices-dotnet

C#
1
star
49

maxscale-cdc-connector

C++
1
star
50

MaxGui

The gui for MaxScale's admin tool
Vue
1
star
51

build-scripts-vagrant

Modified build scripts to work with Vagrant-controlled VMs
Shell
1
star
52

connector-test-machine

Connector test scripts
Shell
1
star