Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/workflows/gh-pages.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ on:
push:
branches:
- master
- psharma/update_readme
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be removed before merging? Or replaced with gh-pages branch name?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes , feature branch will be removed.

paths:
- 'website/**'
workflow_dispatch:
Expand Down Expand Up @@ -39,7 +40,8 @@ jobs:
run: cd website && npm run build

- name: Deploy
uses: peaceiris/actions-gh-pages@v3
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./website/build
uses: peaceiris/actions-gh-pages@v2
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
PUBLISH_BRANCH: gh-pages
PUBLISH_DIR: ./website/build
170 changes: 110 additions & 60 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,101 +14,151 @@
[starttls.js]: https://gist.github.com/TooTallNate/848444
[node-mariasql]: https://github.com/mscdex/node-mariasql
[contributors]: https://github.com/sidorares/node-mysql2/graphs/contributors
[contributing]: https://github.com/sidorares/node-mysql2/blob/master/Contributing.md
[docs-base]: https://sidorares.github.io/node-mysql2/docs
[docs-base-zh-CN]: https://sidorares.github.io/node-mysql2/zh-CN/docs
[docs-base-pt-BR]: https://sidorares.github.io/node-mysql2/pt-BR/docs
[docs-prepared-statements]: https://sidorares.github.io/node-mysql2/docs/documentation/prepared-statements
[docs-mysql-server]: https://sidorares.github.io/node-mysql2/docs/documentation/mysql-server
[docs-promise-wrapper]: https://sidorares.github.io/node-mysql2/docs/documentation/promise-wrapper
[docs-authentication-switch]: https://sidorares.github.io/node-mysql2/docs/documentation/authentication-switch
[contributing]: https://github.com/singlestore-labs/singlestore-nodejs/blob/master/Contributing.md
[docs-base]: https://singlestore-labs.github.io/singlestore-nodejs/docs
[docs-api]: https://singlestore-labs.github.io/singlestore-nodejs/docs/api-and-configurations
[docs-prepared-statements]: https://singlestore-labs.github.io/singlestore-nodejs/docs/documentation/prepared-statements
[docs-mysql-server]: https://singlestore-labs.github.io/singlestore-nodejs/docs/documentation/mysql-server
[docs-promise-wrapper]: https://singlestore-labs.github.io/singlestore-nodejs/documentation/promise-wrapper
[docs-authentication-switch]: https://singlestore-labs.github.io/singlestore-nodejs/docs/documentation/authentication-switch
[docs-streams]: https://sidorares.github.io/node-mysql2/docs/documentation/extras
[docs-typescript-docs]: https://sidorares.github.io/node-mysql2/docs/documentation/typescript-examples
[docs-qs-pooling]: https://sidorares.github.io/node-mysql2/docs#using-connection-pools
[docs-qs-first-query]: https://sidorares.github.io/node-mysql2/docs#first-query
[docs-qs-using-prepared-statements]: https://sidorares.github.io/node-mysql2/docs#using-prepared-statements
[docs-examples]: https://sidorares.github.io/node-mysql2/docs/examples
[docs-faq]: https://sidorares.github.io/node-mysql2/docs/faq
[docs-documentation]: https://sidorares.github.io/node-mysql2/docs/documentation
[docs-contributing]: https://sidorares.github.io/node-mysql2/docs/contributing/website
[coverage]: https://img.shields.io/codecov/c/github/sidorares/node-mysql2
[coverage-url]: https://app.codecov.io/github/sidorares/node-mysql2
[ci-url]: https://github.com/sidorares/node-mysql2/actions/workflows/ci-coverage.yml?query=branch%3Amaster
[ci-image]: https://img.shields.io/github/actions/workflow/status/sidorares/node-mysql2/ci-coverage.yml?event=push&style=flat&label=CI&branch=master

# MySQL2
[docs-qs-pooling]: https://singlestore-labs.github.io/singlestore-nodejs/docs#using-connection-pools
[docs-qs-first-query]: https://singlestore-labs.github.io/singlestore-nodejs/docs#first-query
[docs-qs-using-prepared-statements]: https://singlestore-labs.github.io/singlestore-nodejs/docs#using-prepared-statements
[docs-examples]: https://singlestore-labs.github.io/singlestore-nodejs/docs/examples
[docs-faq]: https://singlestore-labs.github.io/singlestore-nodejs/docs/faq
[docs-documentation]: https://singlestore-labs.github.io/singlestore-nodejs/docs/documentation
[docs-contributing]: https://singlestore-labs.github.io/singlestore-nodejs/docs/contributing
[tests-image]: https://github.com/singlestore-labs/singlestore-nodejs/actions/workflows/tests.yml/badge.svg?branch=master
[tests-url]: https://github.com/singlestore-labs/singlestore-nodejs/actions/workflows/tests.yml
[gh-pages-image]: https://github.com/singlestore-labs/singlestore-nodejs/actions/workflows/gh-pages.yml/badge.svg?branch=master
[gh-pages-url]: https://github.com/singlestore-labs/singlestore-nodejs/actions/workflows/gh-pages.yml

# SingleStore Node.js Driver

> SingleStore client for Node.js with focus on performance. Supports prepared statements, distributed queries, real-time analytics, compression, ssl and much more.

[![NPM Version][npm-image]][npm-url]
[![NPM Downloads][downloads-image]][downloads-url]
[![Node.js Version][node-version-image]][node-version-url]
[![GitHub Workflow Status (with event)][ci-image]][ci-url]
[![Codecov][coverage]][coverage-url]
[![Tests][tests-image]][tests-url]
[![GitHub Pages][gh-pages-image]][gh-pages-url]
[![License][license-image]][license-url]

[English][docs-base] | [简体中文][docs-base-zh-CN] | [Português (BR)][docs-base-pt-BR]

> MySQL client for Node.js with focus on performance. Supports prepared statements, non-utf8 encodings, binary log protocol, compression, ssl [much more][docs-documentation].

**Table of Contents**
## Table of Contents

- [History and Why MySQL2](#history-and-why-mysql2)
- [Why SingleStore Node.js Driver](#why-singlestore-nodejs-driver)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Features](#features)
- [Migration from MySQL2](#migration-from-mysql2)
- [Documentation](#documentation)
- [Acknowledgements](#acknowledgements)
- [Contributing](#contributing)
- [Acknowledgments](#acknowledgments)

## History and Why MySQL2

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

MySQL2 is mostly API compatible with [Node MySQL][node-mysql] and supports majority of features. MySQL2 also offers these additional features:
## Why SingleStore Node.js Driver

- Faster / Better Performance
- [Prepared Statements][docs-prepared-statements]
- MySQL Binary Log Protocol
- [MySQL Server][docs-mysql-server]
- Extended support for Encoding and Collation
- [Promise Wrapper][docs-promise-wrapper]
- Compression
- SSL and [Authentication Switch][docs-authentication-switch]
- [Custom Streams][docs-streams]
- [Pooling][docs-qs-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, with additional optimizations for SingleStore's distributed architecture and analytics capabilities.

## Installation
This driver offers these features optimized for SingleStore:

MySQL2 is free from native bindings and can be installed on Linux, Mac OS or Windows without any issues.
- **Faster / Better Performance** for distributed queries
- **Connection routing** to appropriate nodes (aggregator/leaf)
- **Support for ColumnStore and RowStore** tables
- **Real-time analytics** optimizations
- **Distributed query execution** handling
- **Pipeline data ingestion** support
- **Optimized batch inserts** for high-throughput scenarios
- All existing MySQL2 features (Prepared Statements, Pooling, etc.)

## Installation

```bash
npm install --save mysql2
npm install singlestore-nodejs
```

If you are using TypeScript, you will need to install `@types/node`.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is still useful info


```bash
npm install --save-dev @types/node
## Quick Start

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

> For TypeScript documentation and examples, see [here][docs-typescript-docs].
## Features

- **High Performance**: Optimized for SingleStore's distributed architecture
- **Prepared Statements**: Binary protocol with prepared statements
- **Connection Pooling**: Built-in connection pool management
- **Promise Wrapper**: Native promise support
- **Compression**: Protocol compression support
- **SSL/TLS**: Secure connections
- **Transaction Support**: Full transaction support
- **Streaming**: Stream large result sets
- **TypeScript**: Full TypeScript definitions included

Comment on lines +122 to +132
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be removed - let's keep original features in "History and Why MySQL2" and add new features to "SingleStore-Specific Features"

## Migration from MySQL2

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

```javascript
// 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
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's keep documentation on Github pages and simply link there


- [Quickstart][docs-base]
- [First Query][docs-qs-first-query], [Using Prepared Statements][docs-qs-using-prepared-statements], [Using Connection Pools][docs-qs-pooling] and more.
- [Documentation][docs-documentation]
📚 **Full documentation:** [SingleStore Nodejs Driver][docs-base]

- [Getting Started][docs-documentation]
- [Examples][docs-examples]
- [FAQ][docs-faq]

## Acknowledgements

- Internal protocol is written by [@sidorares][sidorares] [MySQL-Native][mysql-native].
- Constants, SQL parameters interpolation, Pooling, `ConnectionConfig` class taken from [Node MySQL][node-mysql].
- SSL upgrade code based on [@TooTallNate][TooTallNate] [code][starttls.js].
- Secure connection / compressed connection api flags compatible to [MariaSQL][node-mariasql] client.
- [Contributors][contributors].
- [API Reference][docs-api]

## Contributing

Want to improve something in **MySQL2**?
Please check [Contributing.md][contributing] for detailed instruction on how to get started.
Contributions are welcome! Please see [Contributing.md](Contributing.md) for details.

## Acknowledgments

To contribute in **MySQL2 Documentation**, please visit the [Website Contributing Guidelines][docs-contributing] for detailed instruction on how to get started.
This project is a fork of [mysql2](https://github.com/sidorares/node-mysql2) by @sidorares. We are grateful for the excellent foundation provided by the MySQL2 project.
24 changes: 22 additions & 2 deletions website/docs/api-and-configurations.mdx
Original file line number Diff line number Diff line change
@@ -1,11 +1,31 @@
# API and Configuration

[node-mysql]: https://github.com/mysqljs/mysql
[node-mysql2]: https://github.com/sidorares/node-mysql2
[singlestore-docs]: https://docs.singlestore.com/

MySQL2 is mostly API compatible with [Node MySQL][node-mysql].
SingleStore Node.js Driver is mostly API compatible with [node-mysql2][node-mysql2] and [Node MySQL][node-mysql]. Since SingleStore is MySQL wire-protocol compatible, most existing MySQL client code works seamlessly.

## Known Incompatibilities

One known incompatibility is that `DECIMAL` values are returned as strings whereas in [Node MySQL][node-mysql] they are returned as numbers. This includes the result of `SUM()` and `AVG()` functions when applied to `INTEGER` arguments. This is done deliberately to avoid loss of precision - see https://github.com/sidorares/node-mysql2/issues/935.

## Migration from MySQL2

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

```javascript
// 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!
```

:::info
If you find any other incompatibility with [Node MySQL][node-mysql], Please report via Issue tracker. We will fix reported incompatibility on priority basis.
If you find any incompatibility with [node-mysql2][node-mysql2] or issues specific to SingleStoreDB, please report via GitHub issue. We will address reported issues on priority basis.
:::
6 changes: 3 additions & 3 deletions website/docs/contributing/00-index.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
slug: /contributing
title: MySQL2
title: SINGLESTORE-NODEJS
---

import { PageTitle } from '@site/src/components/PageTitle';
Expand All @@ -9,5 +9,5 @@ import { PageTitle } from '@site/src/components/PageTitle';

# Contributing

Want to improve something in **MySQL2**?
Please check [Contributing.md](https://github.com/sidorares/node-mysql2/blob/master/Contributing.md) for detailed instruction on how to get started.
Want to improve something in **singlestore-nodejs**?
Please check [Contributing.md](https://github.com/singlestore-labs/singlestore-nodejs/blob/master/Contributing.md) for detailed instruction on how to get started.
18 changes: 9 additions & 9 deletions website/docs/contributing/website.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ You will need these tools installed on your system:

## Development

1. Fork the [MySQL2](https://github.com/sidorares/node-mysql2) repository.
2. Download your forked repository locally. The website's workspace is the "_website_" directory in **node-mysql2** root.
1. Fork the [SingleStore Node.js Driver](https://github.com/singlestore-labs/singlestore-nodejs) repository.
2. Download your forked repository locally. The website's workspace is the "_website_" directory in **singlestore-nodejs** root.
3. Create a new branch from `master` (optional).
4. Run `cd website` to enter the website workspace.
5. Run `npm ci` to install the dependecies from _package-lock.json_.
6. Run `npm start` to starting the local development.
5. Run `npm ci` to install the dependencies from _package-lock.json_.
6. Run `npm start` to start the local development.

> It will start a local development server and opens up a browser window. Most changes are reflected live without having to restart the server.

Expand All @@ -37,9 +37,9 @@ For **Docusaurus** complete documentation, please [see here](https://docusaurus.
<FAQ title='CLI example'>

```bash
git clone https://github.com/sidorares/node-mysql2.git
git clone https://github.com/singlestore-labs/singlestore-nodejs.git
git checkout -b website # optional
cd /path-to/node-mysql2/website
cd /path-to/singlestore-nodejs/website
npm ci
npm start
```
Expand All @@ -55,7 +55,7 @@ Documentation is auto-generated from **MDX** files placed in these directories:
:::danger Caution
Note that the website has its own _package.json_.

Please, do not install dependencies for the website in **node-mysql2** root.
Please, do not install dependencies for the website in **singlestore-nodejs** root.
:::

<hr />
Expand Down Expand Up @@ -181,12 +181,12 @@ import { ExternalCodeEmbed } from '@site/src/components/ExternalCodeEmbed';

<FAQ title='Example'>
<ExternalCodeEmbed
url='https://raw.githubusercontent.com/sidorares/node-mysql2/master/.prettierrc'
url='https://raw.githubusercontent.com/singlestore-labs/singlestore-nodejs/master/.prettierrc'
language='json'
/>

<ExternalCodeEmbed
url='https://raw.githubusercontent.com/sidorares/node-mysql2/master/tools/parse-row.js'
url='https://raw.githubusercontent.com/singlestore-labs/singlestore-nodejs/master/tools/parse-row.js'
language='js'
extractMethod='parseC'
methodType='function'
Expand Down
23 changes: 10 additions & 13 deletions website/docs/documentation/00-index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ import { PageTitle } from '@site/src/components/PageTitle';

# Documentation

[node-mysql]: https://github.com/mysqljs/mysql
[node-mysql2]: https://github.com/sidorares/node-mysql2
[singlestore-docs]: https://docs.singlestore.com/

MySQL2 aims to be a drop in replacement for [Node MySQL][node-mysql].
**singlestore-nodejs** is a Node.js driver for SingleStoreDB, forked from [node-mysql2][node-mysql2]. It maintains compatibility with the MySQL protocol while providing optimized support for SingleStoreDB features.

:::note
_If you see any API incompatibilities with [Node MySQL][node-mysql], please report via github issue._
_This driver is based on [node-mysql2][node-mysql2] and maintains API compatibility. If you encounter any issues specific to SingleStoreDB, please report via GitHub issue._
:::

Not only **MySQL2** offers better performance over [Node MySQL][node-mysql], we also support these additional features:
**singlestore-nodejs** offers:

- [Prepared Statements](/docs/documentation/prepared-statements)
- [Promise Wrapper](/docs/documentation/promise-wrapper)
Expand All @@ -33,7 +34,7 @@ Not only **MySQL2** offers better performance over [Node MySQL][node-mysql], we

## Examples

Please check these [examples](/docs/examples) for **MySQL2**.
Please check these [examples](/docs/examples) for **singlestore-nodejs**.

<hr />

Expand Down Expand Up @@ -66,17 +67,13 @@ This option could lose precision on the number as Javascript Number is a Float!

## Other Resources

- [Wire protocol documentation](https://dev.mysql.com/doc/internals/en/client-server-protocol.html)
- [Node MySQL][node-mysql] - Most popular node.js mysql client library
- [node-mariasql](https://github.com/mscdex/node-mariasql/) - Bindings to libmariasql. One of the fastest clients
- [node-libmysqlclient](https://github.com/Sannis/node-mysql-libmysqlclient) - Bindings to libmysqlclient
- [go-mysql](https://github.com/siddontang/go-mysql) - MySQL Go client (prepared statements, binlog protocol, server)
- [SingleStoreDB Documentation][singlestore-docs]
- [MySQL Wire Protocol Documentation](https://dev.mysql.com/doc/internals/en/client-server-protocol.html)
- [node-mysql2][node-mysql2] - The upstream MySQL client library this driver is based on

<hr />

## Benchmarks

- https://gist.github.com/sidorares/ffe9ee9c423f763e3b6b
- `npm run benchmarks`
- [node-mysql-benchmarks](https://github.com/mscdex/node-mysql-benchmarks)
- try to run example [benchmarks](https://github.com/sidorares/node-mysql2/tree/master/benchmarks) on your system
- try to run example [benchmarks](https://github.com/singlestore-labs/singlestore-nodejs/tree/master/benchmarks) on your system
Loading
Loading