{"id":21215344,"url":"https://github.com/zlikavac32/sql-query-parser","last_synced_at":"2025-03-15T00:24:37.028Z","repository":{"id":141948463,"uuid":"242675549","full_name":"zlikavac32/sql-query-parser","owner":"zlikavac32","description":"Small SELECT statement SQL parser for query builders","archived":false,"fork":false,"pushed_at":"2020-12-28T15:16:23.000Z","size":207,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-21T16:30:39.037Z","etag":null,"topics":["c","query-builder","sql-parser"],"latest_commit_sha":null,"homepage":"","language":"C","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/zlikavac32.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","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}},"created_at":"2020-02-24T07:44:27.000Z","updated_at":"2022-11-04T11:38:47.000Z","dependencies_parsed_at":"2023-03-13T10:26:40.598Z","dependency_job_id":null,"html_url":"https://github.com/zlikavac32/sql-query-parser","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zlikavac32%2Fsql-query-parser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zlikavac32%2Fsql-query-parser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zlikavac32%2Fsql-query-parser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zlikavac32%2Fsql-query-parser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zlikavac32","download_url":"https://codeload.github.com/zlikavac32/sql-query-parser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243664545,"owners_count":20327492,"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":["c","query-builder","sql-parser"],"created_at":"2024-11-20T21:37:12.589Z","updated_at":"2025-03-15T00:24:36.977Z","avatar_url":"https://github.com/zlikavac32.png","language":"C","readme":"# Tiny SQL Parser\n\n[![Build Status](https://travis-ci.org/zlikavac32/sql-query-parser.svg?branch=master)](https://travis-ci.org/zlikavac32/sql-query-parser)\n\nSmall **ASCII only** SQL parser for the `SELECT` statements intended to be used in query builders. The statement is decomposed into sections and placeholders are collected for each section. Only unnamed placeholders are supported which means that for every placeholder only it's offset within the section is recorded.\n\nCurrently this parser targets MySQL SQL grammar until version `8.0`.\n\nThis library should parse any valid `SELECT` statement but it will also parse some invalid statements as valid. This is by design, since intention is to use this to parse already valid statements and this way grammar is simplified. \n\nFor more info about the library check `include/tsqlp.h`.\n\nWith the library comes standalone binary to decompose `SELECT` statements into sections called `tsqlp`.\n\nFor example, for the SQL\n\n```sql\nSELECT id, 2, ? + ? FROM t WHERE a = ?\n```\n\n`tsqlp` produces output\n\n```text\ncolumns 2 7 11 12 id, 2, ? + ?\ntables 0 1 t\nwhere 1 4 5 a = ?\n```\n\nStatement contains three sections, `columns`, `tables` and `where`. Section `column` has 2 parameters at offsets 7 and 11 and is 12 bytes long. Then comes 12 bytes of the section content. Section `tables` contains 0 parameters and is 1 byte long. Content of the `tables` section is `t`. Finally, `where` section has 1 parameter at offset 4 and the content of that section is `a = ?` which is 5 bytes long.\n\n## Placeholders as table names\n\nThis parser supports placeholders as table name. That is something invalid in regular SQL but it's useful in query building.\n\nFor example, parser can parse `SELECT * FROM ?` and expose `?` as a placeholder which can later have inline subquery or something else.\n\n## Installation\n\nClone this repository and within do the following.\n\n```sh\ncd build\ncmake .. -DCMAKE_BUILD_TYPE=Release \nmake\nsudo make install\n```\n\nIf you get `tsqlp: error while loading shared libraries: libtsqlp.so: cannot open shared object file: No such file or directory` make sure `/usr/local/lib` is used by the `ldconfig` or change install path.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzlikavac32%2Fsql-query-parser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzlikavac32%2Fsql-query-parser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzlikavac32%2Fsql-query-parser/lists"}