{"id":20749681,"url":"https://github.com/splendiddata/pg_sqlparser","last_synced_at":"2025-07-26T20:11:14.732Z","repository":{"id":40685084,"uuid":"312209237","full_name":"splendiddata/pg_sqlparser","owner":"splendiddata","description":"An sql parser that parses PostgreSQL to Java objects","archived":false,"fork":false,"pushed_at":"2024-09-06T10:31:45.000Z","size":5474,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-18T03:27:02.143Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PLpgSQL","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"gpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/splendiddata.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-11-12T08:10:54.000Z","updated_at":"2024-09-06T10:31:50.000Z","dependencies_parsed_at":"2024-06-04T14:18:57.512Z","dependency_job_id":"292bd8c0-839c-4053-ae6d-16e3aa472068","html_url":"https://github.com/splendiddata/pg_sqlparser","commit_stats":null,"previous_names":[],"tags_count":8,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splendiddata%2Fpg_sqlparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splendiddata%2Fpg_sqlparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splendiddata%2Fpg_sqlparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/splendiddata%2Fpg_sqlparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/splendiddata","download_url":"https://codeload.github.com/splendiddata/pg_sqlparser/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243048214,"owners_count":20227593,"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-17T08:24:02.693Z","updated_at":"2025-07-26T20:11:14.697Z","avatar_url":"https://github.com/splendiddata.png","language":"PLpgSQL","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pg_sqlparser\n**An sql parser that parses PostgreSQL to Java objects**\n\nSometimes it may be handy to be able to parse (PostgreSQL) sql statements into Java objects. pg_sqlparser does that.\n\nThe parser is generated directly from the actual PostgreSQL parser sources, so the implementation should come pretty close to what PostgreSQL does itself.\n\n## Features\n* Parses PostgreSQL sql statements to a Java object structure\n* Can visualise the parsed structure in an XML structure\n* Can generate sql statements from the Java object structure\n* Comes with a test GUI to visualise the three features above\n\n## Prerequisites\n* Java **21** or higher\n* Maven 3.5.2 or higher\n* Bison 3.0 or higher\n\n## Usage\nHere is an example of how to use the parser:\n\n```\n   ...\npublic static void main(String[] args) {\n    String sql = \"SELECT a, sum(b) AS total \"\n               + \"FROM tbl \"\n               + \"WHERE a != 'excl' \"\n               + \"GROUP BY a\";\n    List\u003cSqlParserErrorData\u003e parserErrors = new ArrayList\u003c\u003e();\n    try (Reader reader = new StringReader(sql)) {\n        SqlParser parser = new SqlParser(reader\n                                        , error -\u003e parserErrors.add(error)\n                                        );\n        if (parser.parse()) {\n            for (Node parsedStatement : parser.getResult()) {\n                System.out.println(\"The parsed statement = \"\n                                  + parsedStatement\n                                  );\n                System.out.println(\n                        \"The statement in XML format looks like:\\n\"\n                        + ParserUtil.stmtToXml(parsedStatement)\n                        );\n            }\n        } else {\n            for (SqlParserErrorData err : parserErrors) {\n                System.out.println(\"Parser error: \" + err);\n            }\n        }\n    } catch (IOException e) {\n        System.out.println(e);\n    }\n}\n   ...\n```\nMore information can be found in [https://github.com/splendiddata/pg_sqlparser/tree/main/doc/README.pdf](https://github.com/splendiddata/pg_sqlparser/tree/main/doc/README.pdf)\n\n## Branches\nThe Postgres_13 branch contains a parser based on the PostgreSQL 13 parser.\u003cbr\u003e\nThe Postgres_14 branch contains a parser based on the PostgreSQL 14 parser.\u003cbr\u003e\nThe Postgres_15 branch contains a parser based on the PostgreSQL 15 parser.\u003cbr\u003e\nThe Postgres_16 branch contains a parser based on the PostgreSQL 16 parser.\u003cbr\u003e\nThe main branch is based on the PostgreSQL 17 parser.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsplendiddata%2Fpg_sqlparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsplendiddata%2Fpg_sqlparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsplendiddata%2Fpg_sqlparser/lists"}