npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

oceanbase

v0.0.1

Published

fast oceanbase driver. Implements core protocol, prepared statements, ssl and compression in native JS

Downloads

92

Readme

OceanBase Driver for Node.js

NPM Version NPM Downloads Node.js Version GitHub Workflow Status (with event) Codecov License

High-performance OceanBase database client driver built on top of MySQL2. Fully compatible with MySQL protocol, with additional support for OceanBase Oracle tenant protocol. Supports prepared statements, non-utf8 encodings, binary log protocol, compression, SSL and much more.

Table of Contents

About This Driver

This driver is built on top of the MySQL2 project, extending support for OceanBase database while maintaining all MySQL2 functionality.

OceanBase is a distributed relational database that is fully compatible with MySQL protocol. This driver extends the MySQL protocol with additional support for OceanBase Oracle tenant protocol, enabling you to:

  • Connect to OceanBase MySQL tenants using MySQL mode
  • Connect to OceanBase Oracle tenants using Oracle mode
  • Seamlessly migrate existing MySQL2 code without API changes

This driver is fully API compatible with MySQL2, and you can directly refer to the MySQL2 official documentation for usage.

Key Features

OceanBase-Specific Features

  • OceanBase MySQL Tenant Support - Fully compatible with MySQL protocol
  • OceanBase Oracle Tenant Support - Enable Oracle compatibility mode via mode: 'oracle' option
  • Dual Mode Support - Single driver supports both MySQL and Oracle modes

MySQL2 Original Features

  • Faster / Better Performance - Optimized performance
  • 📝 Prepared Statements - Support for prepared statements, improving performance and security
  • 📊 MySQL Binary Log Protocol - Support for binary log parsing
  • 🖥️ MySQL Server - Can create MySQL-compatible servers
  • 🌐 Extended support for Encoding and Collation - Support for multiple character sets and collations
  • 🔄 Promise Wrapper - Native Promise support
  • 🗜️ Compression - Support for connection compression
  • 🔒 SSL and Authentication Switch - Support for SSL connections and multiple authentication methods
  • 🌊 Custom Streams - Support for custom data streams
  • 💧 Connection Pooling - Built-in connection pool management

Installation

This driver is free from native bindings and can be installed on Linux, Mac OS or Windows without any issues.

npm install --save oceanbase

Quick Start

Connecting to OceanBase MySQL Tenant

const oceanbase = require('oceanbase');

const connection = oceanbase.createConnection({
  host: 'localhost',
  user: 'root',
  password: 'password',
  database: 'test'
});

connection.query('SELECT * FROM users', (err, results) => {
  if (err) throw err;
  console.log(results);
});

Connecting to OceanBase Oracle Tenant

const oceanbase = require('oceanbase');

// Use mode: 'oracle' option to enable Oracle mode
const connection = oceanbase.createConnection({
  host: 'localhost',
  user: 'oracle_user',
  password: 'password',
  database: 'oracle_db',
  mode: 'oracle'  // Key: Enable Oracle tenant mode
});

connection.query('SELECT * FROM users', (err, results) => {
  if (err) throw err;
  console.log(results);
});

Connecting with Tenant and Cluster

OceanBase supports cluster and tenant fields. When connecting, you can specify tenant and cluster options, and the driver will automatically format the username as username@tenant#cluster:

const oceanbase = require('oceanbase');

// Using tenant and cluster options
const connection = oceanbase.createConnection({
  host: 'localhost',
  user: 'myuser',
  password: 'password',
  database: 'mydb',
  tenant: 'mytenant',    // Tenant name
  cluster: 'mycluster'   // Cluster name
  // Username will be automatically formatted as: myuser@mytenant#mycluster
});

// You can also use URL query parameters
const connection2 = oceanbase.createConnection({
  uri: 'mysql://myuser:password@localhost:3306/mydb?tenant=mytenant&cluster=mycluster'
});

// If username already contains @ or #, it will be used as-is
const connection3 = oceanbase.createConnection({
  host: 'localhost',
  user: 'myuser@mytenant#mycluster',  // Already formatted
  password: 'password',
  database: 'mydb'
  // tenant and cluster options will be ignored if username is already formatted
});

Using Connection Pool (Oracle Mode)

const oceanbase = require('oceanbase');

const pool = oceanbase.createPool({
  host: 'localhost',
  user: 'oracle_user',
  password: 'password',
  database: 'oracle_db',
  mode: 'oracle'  // Oracle tenant mode
});

pool.query('SELECT * FROM users', (err, results) => {
  if (err) throw err;
  console.log(results);
});

Using Promise API

const oceanbase = require('oceanbase/promise');

async function queryData() {
  const connection = await oceanbase.createConnection({
    host: 'localhost',
    user: 'root',
    password: 'password',
    database: 'test',
    mode: 'oracle'  // Optional: Oracle mode
  });

  const [rows] = await connection.execute('SELECT * FROM users WHERE id = ?', [1]);
  console.log(rows);
  
  await connection.end();
}

Documentation

This driver's usage documentation is fully compatible with MySQL2. You can refer to the following MySQL2 official documentation:

Oracle Mode Notes

When connecting to OceanBase Oracle tenants, you need to add the mode: 'oracle' option to your connection configuration:

{
  host: 'your-host',
  user: 'your-user',
  password: 'your-password',
  database: 'your-database',
  mode: 'oracle'  // Enable Oracle tenant mode
}

When mode is not specified or set to mode: 'mysql', the standard MySQL protocol will be used (suitable for MySQL tenants).

Tenant and Cluster Configuration

OceanBase supports multi-tenant architecture with cluster and tenant concepts. The driver automatically formats usernames when tenant and/or cluster options are provided:

  • tenant (optional): The tenant name. When provided, username will be formatted as username@tenant
  • cluster (optional): The cluster name. When provided, username will be formatted as username@tenant#cluster (if tenant is also provided) or username#cluster (if only cluster is provided)

Note: If the username already contains @ or # characters, the driver will use it as-is and ignore the tenant and cluster options to avoid duplicate formatting.