{"id":22796045,"url":"https://github.com/krasun/gosqlparser","last_synced_at":"2025-07-15T16:35:33.811Z","repository":{"id":50324189,"uuid":"427068728","full_name":"krasun/gosqlparser","owner":"krasun","description":"Simple SQL parser","archived":false,"fork":false,"pushed_at":"2025-01-15T18:02:39.000Z","size":62,"stargazers_count":76,"open_issues_count":0,"forks_count":7,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-07-15T07:35:33.779Z","etag":null,"topics":["go","go-library","golang","lexer","lexer-parser","parser","sql","sqlparser"],"latest_commit_sha":null,"homepage":"","language":"Go","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/krasun.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,"zenodo":null}},"created_at":"2021-11-11T16:27:25.000Z","updated_at":"2025-07-07T08:51:51.000Z","dependencies_parsed_at":"2025-05-20T02:07:29.706Z","dependency_job_id":"8bf220ec-c002-4d19-bf74-8ad56b34f659","html_url":"https://github.com/krasun/gosqlparser","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/krasun/gosqlparser","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krasun%2Fgosqlparser","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krasun%2Fgosqlparser/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krasun%2Fgosqlparser/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krasun%2Fgosqlparser/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/krasun","download_url":"https://codeload.github.com/krasun/gosqlparser/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/krasun%2Fgosqlparser/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265445345,"owners_count":23766450,"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":["go","go-library","golang","lexer","lexer-parser","parser","sql","sqlparser"],"created_at":"2024-12-12T05:09:50.477Z","updated_at":"2025-07-15T16:35:33.775Z","avatar_url":"https://github.com/krasun.png","language":"Go","readme":"# gosqlparser\n\n[![Build](https://github.com/krasun/gosqlparser/actions/workflows/build.yml/badge.svg?branch=main)](https://github.com/krasun/gosqlparser/actions/workflows/build.yml)\n[![Go Report Card](https://goreportcard.com/badge/github.com/krasun/gosqlparser)](https://goreportcard.com/report/github.com/krasun/gosqlparser)\n[![GoDoc](https://godoc.org/https://godoc.org/github.com/krasun/gosqlparser?status.svg)](https://godoc.org/github.com/krasun/gosqlparser)\n\n`gosqlparser` is a simple SQL parser.\n\nUse cases: \n- as part of the database engine; \n- as part of an application API instead of RPC or REST; \n- to query data from CSV and other table-like files.\n\n## Installation\n\nAs simple as:\n\n```\ngo get github.com/krasun/gosqlparser\n```\n\n## Usage \n\n```go\npackage gosqlparser_test\n\nimport (\n\t\"fmt\"\n\n\t\"encoding/json\"\n\n\tsql \"github.com/krasun/gosqlparser\"\n)\n\nfunc Example() {\n\tquery, err := sql.Parse(\"SELECT col1, col2 FROM table1 WHERE col1 == \\\"abc\\\" AND col3 == 5 LIMIT 10\")\n\tif err != nil {\n\t\tfmt.Printf(\"unexpected error: %s\", err)\n\t\treturn\n\t}\n\n\tjson, err := json.Marshal(query)\n\tif err != nil {\n\t\tfmt.Printf(\"unexpected error: %s\", err)\n\t\treturn\n\t}\n\n\tfmt.Println(string(json))\n\t// Output:\n\t// {\"Table\":\"table1\",\"Columns\":[\"col1\",\"col2\"],\"Where\":{\"Expr\":{\"Left\":{\"Left\":{\"Name\":\"col1\"},\"Operator\":0,\"Right\":{\"Value\":\"\\\"abc\\\"\"}},\"Operator\":1,\"Right\":{\"Left\":{\"Name\":\"col3\"},\"Operator\":0,\"Right\":{\"Value\":\"5\"}}}},\"Limit\":\"10\"}\n}\n```\n\n## Supported Statements\n\nCREATE: \n```\nCREATE TABLE table1 (c1 INTEGER, c2 STRING)\n```\n\nDROP: \n```\nDROP TABLE table1\n```\n\nSELECT: \n```\nSELECT c1, c2 FROM table1 WHERE c3 == c4 AND c5 == c6\n```\n\nINSERT: \n```\nINSERT INTO table1 (c1, c2, c3) VALUES (5, \"some string\", 10)\n```\n\nUPDATE: \n```\nUPDATE table1 SET c1 = 10 WHERE c1 == 5 AND c3 == \"quoted string\"\n```\n\nDELETE: \n```\nDELETE FROM table1 WHERE c1 == 5 AND c3 == \"quoted string\"\n```\n\n## Placeholders\nIt is possible to use placeholders by including identifiers between curly brackets.\n```\nSELECT c1, c2 FROM table1 WHERE c3 == {0} AND c4 == {p}\n```\n\n## Tests \n\nTo make sure that the code is fully tested and covered:\n\n```\n$ go test .\nok  \tgithub.com/krasun/gosqlparser\t0.470s\n```\n\n## Known Usages \n\n1. [krasun/gosqldb](https://github.com/krasun/gosqldb) - my experimental implementation of a simple database.\n\n## License \n\n**gosqlparser** is released under [the MIT license](LICENSE).\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrasun%2Fgosqlparser","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkrasun%2Fgosqlparser","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkrasun%2Fgosqlparser/lists"}