Skip to content

singlestore-labs/singlestore-nodejs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

SingleStore Node.js Driver

SingleStore client for Node.js with focus on performance. Supports configurable connection behavior, prepared statements, compression, ssl and much more.

NPM Version NPM Downloads Node.js Version Tests GitHub Pages License

Table of Contents

History and Why MySQL2

MySQL2 project is a continuation of MySQL-Native. Protocol parser code was rewritten from scratch and api changed to match popular Node MySQL. MySQL2 team is working together with Node MySQL team to factor out shared code and move it under mysqljs organization.

MySQL2 is mostly API compatible with Node MySQL and supports majority of features. MySQL2 also offers these additional features:

Why SingleStore Node.js Driver

The SingleStore Node.js Driver is a fork of mysql2, adapted specifically for SingleStore database. Since SingleStore is MySQL wire-protocol compatible, most mysql2 features work seamlessly.

SingleStore Node.js Driver is mostly API compatible with node-mysql and node-mysql2 and supports majority of features.

  • Official SingleStore Support: Officially supported by SingleStore for guaranteed compatibility and reliability
  • Consistent Data Type Handling: Handles SingleStore data types more consistently than generic MySQL drivers
  • Configurable Connection Behavior: Allows you to configure connection behavior by setting session variables
  • MySQL Compatibility: Maintains full compatibility with MySQL wire protocol

For more information about SingleStore, visit the official documentation.

Installation

npm install singlestore-nodejs

If you are using TypeScript, you will need to install @types/node.

Quick Start

const singlestore = require('singlestore_nodejs');

// Create connection
const connection = singlestore.createConnection({
  host: 'localhost',
  user: 'root',
  password: 'password',
  database: 'mydb',
  port: 3306,
});

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

// Using promises
connection
  .promise()
  .query('SELECT * FROM products')
  .then(([rows, fields]) => {
    console.log(rows);
  })
  .catch(console.error);

// Close connection
connection.end();

Migration from MySQL2

SingleStore Node.js Driver is API-compatible with MySQL2, so migration is straightforward:

// Before (MySQL2)
const mysql = require('mysql2');
const connection = mysql.createConnection({...});

// After (SingleStore Node.js Driver)
const singlestore = require('singlestore_nodejs');
const connection = singlestore.createConnection({...});

// All existing queries work as-is!

Documentation

📚 Full documentation: SingleStore Nodejs Driver

Contributing

Contributions are welcome! Please see Contributing.md for details.

Acknowledgments

This project is a fork of mysql2 by @sidorares. We are grateful for the excellent foundation provided by the MySQL2 project.

About

⚡ fast mysqljs/mysql compatible mysql driver for node.js

Resources

License

Code of conduct

Contributing

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 93.0%
  • TypeScript 6.5%
  • Other 0.5%