dbgate/packages/query-splitter
2021-06-03 11:27:49 +02:00
..
src query splitter refactor 2021-06-03 11:27:49 +02:00
.gitignore query-splitter renamamed 2021-06-02 21:02:28 +02:00
jest.config.js query-splitter renamamed 2021-06-02 21:02:28 +02:00
package.json query-splitter - documentation, publish 2021-06-03 07:40:35 +02:00
README.md query-splitter readne 2021-06-03 07:41:59 +02:00
tsconfig.json query-splitter renamamed 2021-06-02 21:02:28 +02:00

NPM version

dbgate-query-splitter

Splits long SQL query into into particular statements. Designed to have zero dependencies and to be fast.

Supports following SQL dialects:

  • MySQL
  • PostgreSQL
  • SQLite
  • Microsoft SQL Server

Usage

import { splitQuery, mysqlSplitterOptions, mssqlSplitterOptions, postgreSplitterOptions } from 'dbgate-query-splitter';

const output = splitQuery('SELECT * FROM `table1`;SELECT * FROM `table2`;', mysqlSplitterOptions);

// output is ['SELECT * FROM `table1`', 'SELECT * FROM `table2`']

Contributing

Please run tests before pushing any changes.

yarn test

Supported syntax

  • Comments
  • Dollar strings (PostgreSQL)
  • GO separators (MS SQL)
  • Custom delimiter, setby DELIMITER keyword (MySQL)