{"id":19594622,"url":"https://github.com/dbgate/dbgate-query-splitter","last_synced_at":"2025-04-27T15:34:10.185Z","repository":{"id":106125617,"uuid":"478840544","full_name":"dbgate/dbgate-query-splitter","owner":"dbgate","description":null,"archived":false,"fork":false,"pushed_at":"2025-01-03T13:23:09.000Z","size":103,"stargazers_count":5,"open_issues_count":0,"forks_count":4,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-05T01:11:10.540Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dbgate.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null},"funding":{"github":"dbgate","patreon":null,"open_collective":"dbgate","ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2022-04-07T05:32:00.000Z","updated_at":"2025-01-03T13:23:13.000Z","dependencies_parsed_at":"2024-02-09T15:04:15.725Z","dependency_job_id":"008f2209-bd83-46f1-9633-9b821a326a86","html_url":"https://github.com/dbgate/dbgate-query-splitter","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbgate%2Fdbgate-query-splitter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbgate%2Fdbgate-query-splitter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbgate%2Fdbgate-query-splitter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dbgate%2Fdbgate-query-splitter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dbgate","download_url":"https://codeload.github.com/dbgate/dbgate-query-splitter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251162862,"owners_count":21545835,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-11T08:44:18.678Z","updated_at":"2025-04-27T15:34:05.156Z","avatar_url":"https://github.com/dbgate.png","language":"TypeScript","funding_links":["https://github.com/sponsors/dbgate","https://opencollective.com/dbgate"],"categories":[],"sub_categories":[],"readme":"[![NPM version](https://img.shields.io/npm/v/dbgate-query-splitter.svg)](https://www.npmjs.com/package/dbgate-query-splitter)\n\n# dbgate-query-splitter\n\nSplits long SQL query into into particular statements. Designed to have zero dependencies and to be fast. Also supports nodejs-streams.\n\nSupports following SQL dialects:\n\n- MySQL\n- PostgreSQL\n- SQLite\n- Microsoft SQL Server\n- Oracle\n\n## Usage\n\n```js\nimport {\n  splitQuery,\n  mysqlSplitterOptions,\n  mssqlSplitterOptions,\n  postgreSplitterOptions,\n} from \"dbgate-query-splitter\";\n\nconst output = splitQuery(\n  \"SELECT * FROM `table1`;SELECT * FROM `table2`;\",\n  mysqlSplitterOptions\n);\n\n// output is ['SELECT * FROM `table1`', 'SELECT * FROM `table2`']\n```\n\n## Streaming support in nodejs\n\nFunction splitQueryStream accepts input stream and query options. Result is object stream, each object for one splitted query. From version 4.9.0, piping byline stream is not required.\n\n```js\nconst {\n  mysqlSplitterOptions,\n  mssqlSplitterOptions,\n  postgreSplitterOptions,\n} = require(\"dbgate-query-splitter\");\nconst {\n  splitQueryStream,\n} = require(\"dbgate-query-splitter/lib/splitQueryStream\");\nconst fs = require(\"fs\");\n\nconst fileStream = fs.createReadStream(\"INPUT_FILE_NAME\", \"utf-8\");\nconst splittedStream = splitQueryStream(fileStream, mysqlSplitterOptions);\n```\n\n## Return rich info\n\nBy default, string array is returned. However, if you need to return row/column number information for splitted commands, use returnRichInfo option:\n\n```js\nimport { splitQuery, mysqlSplitterOptions } from \"dbgate-query-splitter\";\n\nconst output = splitQuery(\"SELECT * FROM `table1`;SELECT * FROM `table2`;\", {\n  ...mysqlSplitterOptions,\n  returnRichInfo: true,\n});\n\n```\n\nOutput is:\n```js\n[\n    {\n        text: 'SELECT * FROM `table1`',\n        start: { position: 0, line: 0, column: 0 },\n        end: { position: 22, line: 0, column: 22 },\n        trimStart: { position: 0, line: 0, column: 0 },\n        trimEnd: { position: 22, line: 0, column: 22 }\n    },\n    {\n        text: 'SELECT * FROM `table2`',\n        start: { position: 23, line: 0, column: 23 },\n        end: { position: 46, line: 1, column: 22 },\n        trimStart: { position: 24, line: 1, column: 0 },\n        trimEnd: { position: 46, line: 1, column: 22 }\n    }\n]\n```\n\n## Contributing\n\nPlease run tests before pushing any changes.\n\n```sh\nyarn test\n```\n\n## Supported syntax\n\n- Comments\n- Dollar strings (PostgreSQL)\n- GO separators (MS SQL)\n- Custom delimiter, setby DELIMITER keyword (MySQL)\n- Slash separator (Oracle)\n- SET SQLTERMINATOR (Oracle)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbgate%2Fdbgate-query-splitter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdbgate%2Fdbgate-query-splitter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdbgate%2Fdbgate-query-splitter/lists"}