{"id":21181772,"url":"https://github.com/altenwald/sqlparser","last_synced_at":"2025-07-10T00:31:26.037Z","repository":{"id":57552046,"uuid":"89713834","full_name":"altenwald/sqlparser","owner":"altenwald","description":"SQL Parsers","archived":false,"fork":false,"pushed_at":"2018-04-10T12:19:10.000Z","size":812,"stargazers_count":5,"open_issues_count":0,"forks_count":2,"subscribers_count":7,"default_branch":"master","last_synced_at":"2024-10-30T16:56:29.600Z","etag":null,"topics":["erlang-libraries","parser","sql"],"latest_commit_sha":null,"homepage":null,"language":"Erlang","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/altenwald.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-04-28T14:27:32.000Z","updated_at":"2021-05-25T08:09:12.000Z","dependencies_parsed_at":"2022-09-26T18:41:41.123Z","dependency_job_id":null,"html_url":"https://github.com/altenwald/sqlparser","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altenwald%2Fsqlparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altenwald%2Fsqlparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altenwald%2Fsqlparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/altenwald%2Fsqlparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/altenwald","download_url":"https://codeload.github.com/altenwald/sqlparser/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":225606653,"owners_count":17495551,"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":["erlang-libraries","parser","sql"],"created_at":"2024-11-20T17:52:21.891Z","updated_at":"2024-11-20T17:52:22.586Z","avatar_url":"https://github.com/altenwald.png","language":"Erlang","readme":"SQL Parser\n==========\n\n[![Build Status](https://img.shields.io/travis/altenwald/sqlparser/master.svg)](https://travis-ci.org/altenwald/sqlparser)\n[![Codecov](https://img.shields.io/codecov/c/github/altenwald/sqlparser.svg)](https://codecov.io/gh/altenwald/sqlparser)\n[![License: LGPL 2.1](https://img.shields.io/github/license/altenwald/sqlparser.svg)](https://raw.githubusercontent.com/altenwald/sqlparser/master/COPYING)\n[![Hex](https://img.shields.io/hexpm/v/sqlparser.svg)](https://hex.pm/packages/sqlparser)\n\nSQL Parsers let you to parse SQL strings to generic SQL records.\n\nUsage\n-----\n\nIf you want to use, only add this in `rebar.config` using [rebar3](https://rebar3.org):\n\n```erlang\n{deps, [\n    {sqlparser, \"0.3.1\"}\n]}.\n```\n\nThe way to use it in the code:\n\n```\n-include_lib(\"sqlparser/include/sqlparser.hrl\").\n\nparsing(SQL) -\u003e\n    mysql_parser:parse(SQL).\n```\n\nYou can use two different parsers at this moment: `mysql_parser` and `sql92_parser`. The second one was included from [sqlapi](https://github.com/flussonic/sqlapi). Both are intended to do the same but `mysql_parser` is more complete and less prone to fail and `sql92_parser` is faster (a lot more):\n\n```\n1\u003e CompareNew = fun(Q) -\u003e timer:tc(fun() -\u003e sql92_parser:parse(Q) end) end.\n2\u003e CompareLegacy = fun(Q) -\u003e timer:tc(fun() -\u003e mysql_parser:parse(Q) end) end.\n3\u003e CompareNew(\"SELECT name, surname, nickname FROM users WHERE country = 'Spain'\").\n{63,\n {select,[{key,\u003c\u003c\"name\"\u003e\u003e,\u003c\u003c\"name\"\u003e\u003e,undefined},\n          {key,\u003c\u003c\"surname\"\u003e\u003e,\u003c\u003c\"surname\"\u003e\u003e,undefined},\n          {key,\u003c\u003c\"nickname\"\u003e\u003e,\u003c\u003c\"nickname\"\u003e\u003e,undefined}],\n         [{table,\u003c\u003c\"users\"\u003e\u003e,\u003c\u003c\"users\"\u003e\u003e}],\n         {condition,eq,\n                    {key,\u003c\u003c\"country\"\u003e\u003e,\u003c\u003c\"country\"\u003e\u003e,undefined},\n                    {value,undefined,\u003c\u003c\"Spain\"\u003e\u003e}},\n         undefined,undefined,undefined,undefined}}\n4\u003e CompareLegacy(\"SELECT name, surname, nickname FROM users WHERE country = 'Spain'\").\n{1803,\n {select,[{key,\u003c\u003c\"name\"\u003e\u003e,\u003c\u003c\"name\"\u003e\u003e,undefined},\n          {key,\u003c\u003c\"surname\"\u003e\u003e,\u003c\u003c\"surname\"\u003e\u003e,undefined},\n          {key,\u003c\u003c\"nickname\"\u003e\u003e,\u003c\u003c\"nickname\"\u003e\u003e,undefined}],\n         [{table,\u003c\u003c\"users\"\u003e\u003e,\u003c\u003c\"users\"\u003e\u003e}],\n         {condition,eq,\n                    {key,\u003c\u003c\"country\"\u003e\u003e,\u003c\u003c\"country\"\u003e\u003e,undefined},\n                    {value,undefined,\u003c\u003c\"Spain\"\u003e\u003e}},\n         undefined,undefined,undefined,undefined}}\n```\n\nFor the same query `mysql_parser` takes 1803 microseconds (or 1,8 ms) and `sql92` takes 63 microseconds (or 0,06 ms).\n\nEnjoy!\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faltenwald%2Fsqlparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faltenwald%2Fsqlparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faltenwald%2Fsqlparser/lists"}