SingleStore client for Node.js with focus on performance. Supports configurable connection behavior, prepared statements, compression, ssl and much more.
- History and Why MySQL2
- Why SingleStore Node.js Driver
- Installation
- Quick Start
- Migration from MySQL2
- Documentation
- Contributing
- Acknowledgments
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:
- Faster / Better Performance
- Prepared Statements
- MySQL Binary Log Protocol
- MySQL Server
- Extended support for Encoding and Collation
- Promise Wrapper
- Compression
- SSL and Authentication Switch
- Custom Streams
- Pooling
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.
npm install singlestore-nodejsIf you are using TypeScript, you will need to install @types/node.
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();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!📚 Full documentation: SingleStore Nodejs Driver
Contributions are welcome! Please see Contributing.md for details.
This project is a fork of mysql2 by @sidorares. We are grateful for the excellent foundation provided by the MySQL2 project.