# tree-sitter-sql
[](https://github.com/derekstride/tree-sitter-sql/actions/workflows/ci.yml)
[](https://github.com/DerekStride/tree-sitter-sql/actions/workflows/gh-pages.yml)
[](https://www.npmjs.com/package/@derekstride/tree-sitter-sql)
A general/permissive SQL grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter).
## Installation
**We don't commit the generated parser files to the `main` branch.** Instead, you can find them on the
[gh-pages](https://github.com/DerekStride/tree-sitter-sql/tree/gh-pages) branch. We're open to feedback & encourage you
to [open an issue](https://github.com/DerekStride/tree-sitter-sql/issues/new) to discuss any problems.
They are also hosted on the [GitHub pages site](https://derek.stride.host/tree-sitter-sql/) and available for download
here:
[github://derekstride/tree-sitter-sql/gh-pages.tar.gz](https://github.com/DerekStride/tree-sitter-sql/archive/refs/heads/gh-pages.tar.gz).
*Plugin maintainers ensure to specify the `HEAD` (or a specific revision) of the `gh-pages` branch when integrating
with this project.*
### Step 1: Download the parser files
**Using `git`**
```bash
git clone https://github.com/DerekStride/tree-sitter-sql.git
cd tree-sitter-sql
git checkout gh-pages
```
**Using `curl`**
```bash
curl -LO https://github.com/DerekStride/tree-sitter-sql/archive/refs/heads/gh-pages.tar.gz
tar -xzf gh-pages.tar.gz
cd tree-sitter-sql-gh-pages
```
### Step 2: Compile the Parser
Tree-sitter parsers need to be compiled as a shared-object / dynamic-library, you can enable this by passing the
`-shared` & `-fPIC` flags to your compiler.
```bash
cc -shared -fPIC -I./src src/parser.c src/scanner.c -o sql.so
```
### Using [cargo](https://crates.io/crates/tree-sitter-sequel)
```bash
cargo add tree-sitter-sequel
```
### Using [npm](https://www.npmjs.com/package/@derekstride/tree-sitter-sql)
```bash
npm i @derekstride/tree-sitter-sql
```
### Using [pip](https://pypi.org/project/tree-sitter-sql/0.3.5/)
```bash
pip install tree-sitter-sql
```
## Development
See [CONTRIBUTING.md](CONTRIBUTING.md) for documentation on how to set up the project for development.
## Features
For a complete list of features see the the [tests](test/corpus)
## References
* [Wikipedia#SQL_syntax](https://en.wikipedia.org/wiki/SQL_syntax) - I consulted wikipedia for naming conventions,
though I may not have been strict early on in the prototyping.
* [Phoenix Language Reference](https://forcedotcom.github.io/phoenix/index.html) - A reference diagram.
* [SQLite's railroad diagram for expr](https://www.sqlite.org/lang_expr.html) - Another reference diagram.
* [Postgresql syntax documentation](https://www.postgresql.org/docs/current/sql-commands.html)
* [Mariadb syntax documentation](https://mariadb.com/kb/en/sql-statements-structure/)
### Other projects
* https://github.com/m-novikov/tree-sitter-sql
* https://github.com/tjdevries/tree-sitter-sql
* https://github.com/dhcmrlchtdj/tree-sitter-sqlite
Raw data
{
"_id": null,
"home_page": null,
"name": "tree-sitter-sql",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.9",
"maintainer_email": null,
"keywords": "incremental, parsing, tree-sitter, sql",
"author": "derek stride",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/2a/e6/7453a693e440d49916b9672963d98cb0c1bbe94f115014582e93beeff8a3/tree_sitter_sql-0.3.8.tar.gz",
"platform": null,
"description": "# tree-sitter-sql\n\n[](https://github.com/derekstride/tree-sitter-sql/actions/workflows/ci.yml)\n[](https://github.com/DerekStride/tree-sitter-sql/actions/workflows/gh-pages.yml)\n[](https://www.npmjs.com/package/@derekstride/tree-sitter-sql)\n\n\nA general/permissive SQL grammar for [tree-sitter](https://github.com/tree-sitter/tree-sitter).\n\n## Installation\n\n**We don't commit the generated parser files to the `main` branch.** Instead, you can find them on the\n[gh-pages](https://github.com/DerekStride/tree-sitter-sql/tree/gh-pages) branch. We're open to feedback & encourage you\nto [open an issue](https://github.com/DerekStride/tree-sitter-sql/issues/new) to discuss any problems.\n\nThey are also hosted on the [GitHub pages site](https://derek.stride.host/tree-sitter-sql/) and available for download\nhere:\n[github://derekstride/tree-sitter-sql/gh-pages.tar.gz](https://github.com/DerekStride/tree-sitter-sql/archive/refs/heads/gh-pages.tar.gz).\n\n*Plugin maintainers ensure to specify the `HEAD` (or a specific revision) of the `gh-pages` branch when integrating\nwith this project.*\n\n### Step 1: Download the parser files\n\n**Using `git`**\n```bash\ngit clone https://github.com/DerekStride/tree-sitter-sql.git\ncd tree-sitter-sql\ngit checkout gh-pages\n```\n\n**Using `curl`**\n```bash\ncurl -LO https://github.com/DerekStride/tree-sitter-sql/archive/refs/heads/gh-pages.tar.gz\ntar -xzf gh-pages.tar.gz\ncd tree-sitter-sql-gh-pages\n```\n\n### Step 2: Compile the Parser\n\nTree-sitter parsers need to be compiled as a shared-object / dynamic-library, you can enable this by passing the\n`-shared` & `-fPIC` flags to your compiler.\n\n```bash\ncc -shared -fPIC -I./src src/parser.c src/scanner.c -o sql.so\n```\n\n### Using [cargo](https://crates.io/crates/tree-sitter-sequel)\n\n```bash\ncargo add tree-sitter-sequel\n```\n\n### Using [npm](https://www.npmjs.com/package/@derekstride/tree-sitter-sql)\n\n```bash\nnpm i @derekstride/tree-sitter-sql\n```\n\n### Using [pip](https://pypi.org/project/tree-sitter-sql/0.3.5/)\n\n```bash\npip install tree-sitter-sql\n```\n\n## Development\n\nSee [CONTRIBUTING.md](CONTRIBUTING.md) for documentation on how to set up the project for development.\n\n## Features\n\nFor a complete list of features see the the [tests](test/corpus)\n\n## References\n\n* [Wikipedia#SQL_syntax](https://en.wikipedia.org/wiki/SQL_syntax) - I consulted wikipedia for naming conventions,\n though I may not have been strict early on in the prototyping.\n* [Phoenix Language Reference](https://forcedotcom.github.io/phoenix/index.html) - A reference diagram.\n* [SQLite's railroad diagram for expr](https://www.sqlite.org/lang_expr.html) - Another reference diagram.\n* [Postgresql syntax documentation](https://www.postgresql.org/docs/current/sql-commands.html)\n* [Mariadb syntax documentation](https://mariadb.com/kb/en/sql-statements-structure/)\n\n### Other projects\n\n* https://github.com/m-novikov/tree-sitter-sql\n* https://github.com/tjdevries/tree-sitter-sql\n* https://github.com/dhcmrlchtdj/tree-sitter-sqlite\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Tree-sitter Grammar for SQL",
"version": "0.3.8",
"project_urls": {
"Homepage": "https://github.com/derekstride/tree-sitter-sql.git"
},
"split_keywords": [
"incremental",
" parsing",
" tree-sitter",
" sql"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "703da5466e79584791cc718c19d56d9cad12d6100f344051cad3f46d09c5dfac",
"md5": "c2613b32d4a3960212e8d7d6bbb1eb7b",
"sha256": "97c77a0447c9fbada9d66ccf21842fab4e79f2d0add940898dc4285cf450824c"
},
"downloads": -1,
"filename": "tree_sitter_sql-0.3.8-cp38-abi3-macosx_10_9_x86_64.whl",
"has_sig": false,
"md5_digest": "c2613b32d4a3960212e8d7d6bbb1eb7b",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.9",
"size": 280609,
"upload_time": "2025-02-13T16:08:02",
"upload_time_iso_8601": "2025-02-13T16:08:02.339891Z",
"url": "https://files.pythonhosted.org/packages/70/3d/a5466e79584791cc718c19d56d9cad12d6100f344051cad3f46d09c5dfac/tree_sitter_sql-0.3.8-cp38-abi3-macosx_10_9_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "7f2c9d6f2b684515b0b75a31dc53ac8018822074bf21e744a77499b8c37fa1b2",
"md5": "b9c7bbd74a3e3ab4ea975b0738f6c484",
"sha256": "6ceef7e5070e519bf32d4a10e602e1e0fe38c0ac277318e595b98461be809ba1"
},
"downloads": -1,
"filename": "tree_sitter_sql-0.3.8-cp38-abi3-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "b9c7bbd74a3e3ab4ea975b0738f6c484",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.9",
"size": 296161,
"upload_time": "2025-02-13T16:08:03",
"upload_time_iso_8601": "2025-02-13T16:08:03.883499Z",
"url": "https://files.pythonhosted.org/packages/7f/2c/9d6f2b684515b0b75a31dc53ac8018822074bf21e744a77499b8c37fa1b2/tree_sitter_sql-0.3.8-cp38-abi3-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "69c2f9a16f4a5a698c8dee446006208ed8c62934292b66cba10f98680a1e4326",
"md5": "40f139cf4d3f886229c91f12f928e71f",
"sha256": "b98981b827d83d47aaaff49ba3180f481504dc2cc41d106f84c8c6111553a430"
},
"downloads": -1,
"filename": "tree_sitter_sql-0.3.8-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"has_sig": false,
"md5_digest": "40f139cf4d3f886229c91f12f928e71f",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.9",
"size": 336519,
"upload_time": "2025-02-13T16:08:05",
"upload_time_iso_8601": "2025-02-13T16:08:05.570573Z",
"url": "https://files.pythonhosted.org/packages/69/c2/f9a16f4a5a698c8dee446006208ed8c62934292b66cba10f98680a1e4326/tree_sitter_sql-0.3.8-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "6c64de6ea4418db54ffc87630d49fa30a76a83774c73d2402cd7c8a3d6db0d10",
"md5": "d4d340566a07bea6834dbd80998b93f0",
"sha256": "ef00e0b30d62ec1d97fbfc3a3c1e9bf4c01aef6de50a29ad95de8452b848c149"
},
"downloads": -1,
"filename": "tree_sitter_sql-0.3.8-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "d4d340566a07bea6834dbd80998b93f0",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.9",
"size": 334223,
"upload_time": "2025-02-13T16:08:06",
"upload_time_iso_8601": "2025-02-13T16:08:06.935986Z",
"url": "https://files.pythonhosted.org/packages/6c/64/de6ea4418db54ffc87630d49fa30a76a83774c73d2402cd7c8a3d6db0d10/tree_sitter_sql-0.3.8-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "0c442723c54e0309cda89f643457d40511acdd908f70408728ad6a5c4aa5bc88",
"md5": "40932e67120f5ec2290d89dadda73fd3",
"sha256": "18268daaca95e38ed0f3b751defc213c07263576f864eaa2a44f642a54f1ff18"
},
"downloads": -1,
"filename": "tree_sitter_sql-0.3.8-cp38-abi3-musllinux_1_2_x86_64.whl",
"has_sig": false,
"md5_digest": "40932e67120f5ec2290d89dadda73fd3",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.9",
"size": 335663,
"upload_time": "2025-02-13T16:08:08",
"upload_time_iso_8601": "2025-02-13T16:08:08.455775Z",
"url": "https://files.pythonhosted.org/packages/0c/44/2723c54e0309cda89f643457d40511acdd908f70408728ad6a5c4aa5bc88/tree_sitter_sql-0.3.8-cp38-abi3-musllinux_1_2_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "009338f26ed9760520b7f29d7328b8211081945dc846a32ff0b0daaaef7af681",
"md5": "a907c6e79b49140c8d3b8f10ecb794b3",
"sha256": "bd2832b719d4d3b1560f06fdfabbdb95d1119e8debb96b9b95d1177fe4fccf4c"
},
"downloads": -1,
"filename": "tree_sitter_sql-0.3.8-cp38-abi3-win_amd64.whl",
"has_sig": false,
"md5_digest": "a907c6e79b49140c8d3b8f10ecb794b3",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.9",
"size": 302976,
"upload_time": "2025-02-13T16:08:10",
"upload_time_iso_8601": "2025-02-13T16:08:10.378534Z",
"url": "https://files.pythonhosted.org/packages/00/93/38f26ed9760520b7f29d7328b8211081945dc846a32ff0b0daaaef7af681/tree_sitter_sql-0.3.8-cp38-abi3-win_amd64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "0dd9dd32d7b74e20dd057d74fb21be0af3e6a1be69709494092fcc3a560200b0",
"md5": "00d4949836f9667b879630ac45f97567",
"sha256": "5630369688f3eecc59740f2e48e23ac5b905961ad2e8b6a1bcee80a212f85727"
},
"downloads": -1,
"filename": "tree_sitter_sql-0.3.8-cp38-abi3-win_arm64.whl",
"has_sig": false,
"md5_digest": "00d4949836f9667b879630ac45f97567",
"packagetype": "bdist_wheel",
"python_version": "cp38",
"requires_python": ">=3.9",
"size": 286947,
"upload_time": "2025-02-13T16:08:12",
"upload_time_iso_8601": "2025-02-13T16:08:12.357800Z",
"url": "https://files.pythonhosted.org/packages/0d/d9/dd32d7b74e20dd057d74fb21be0af3e6a1be69709494092fcc3a560200b0/tree_sitter_sql-0.3.8-cp38-abi3-win_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "2ae67453a693e440d49916b9672963d98cb0c1bbe94f115014582e93beeff8a3",
"md5": "36f52911abce450c8fadfc738398f790",
"sha256": "b1fb94ad6902d46ae26718c0144b55d1a6ef2b60ea5d9184850f8f79b64ec4a1"
},
"downloads": -1,
"filename": "tree_sitter_sql-0.3.8.tar.gz",
"has_sig": false,
"md5_digest": "36f52911abce450c8fadfc738398f790",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.9",
"size": 715158,
"upload_time": "2025-02-13T16:08:14",
"upload_time_iso_8601": "2025-02-13T16:08:14.325904Z",
"url": "https://files.pythonhosted.org/packages/2a/e6/7453a693e440d49916b9672963d98cb0c1bbe94f115014582e93beeff8a3/tree_sitter_sql-0.3.8.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-02-13 16:08:14",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "derekstride",
"github_project": "tree-sitter-sql",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "tree-sitter-sql"
}