Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/blastrain/vitess-sqlparser
simply SQL Parser for Go ( powered by vitess and TiDB )
https://github.com/blastrain/vitess-sqlparser
ddl-parser go golang golang-library mysql sql-parser
Last synced: about 2 months ago
JSON representation
simply SQL Parser for Go ( powered by vitess and TiDB )
- Host: GitHub
- URL: https://github.com/blastrain/vitess-sqlparser
- Owner: blastrain
- License: apache-2.0
- Created: 2017-08-09T08:32:20.000Z (over 7 years ago)
- Default Branch: develop
- Last Pushed: 2022-11-14T17:12:15.000Z (about 2 years ago)
- Last Synced: 2024-08-03T17:17:31.891Z (5 months ago)
- Topics: ddl-parser, go, golang, golang-library, mysql, sql-parser
- Language: Go
- Homepage:
- Size: 6.84 MB
- Stars: 417
- Watchers: 22
- Forks: 74
- Open Issues: 16
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- go-awesome - vitess-sqlparser - SQL parsing (Open source library / Database)
README
# vitess-sqlparser
Simply SQL and DDL parser for Go (powered by vitess and TiDB )
this library inspired by https://github.com/xwb1989/sqlparser(original source : https://github.com/youtube/vitess/tree/master/go/vt/sqlparser)
# Why
[xwb1989/sqlparser](https://github.com/xwb1989/sqlparser) is famous sql parser in Go.
But it cannot parse some query (like offset or bulk insert...) because it customizes vitess's sql parser.Also, some libraries use from vitess sql parser directly. But vitess's sql parser only partial supports DDL parsing.
We want to perfectly support parsing for SQL and DDL.
Therefore we use vitess sql parser directly and also use TiDB parser for DDL parsing.# Compare SQL parser libraries in Go
| library | supports offset (or other complexity) query | supports DDL |
|:---:|:---:|:---:|
|xwb1989/sqlparser |✗ | △|
|zhenjl/sqlparser | ○|△ |
|knocknote/vitess-sqlparser|○|○|# Installation
## [NOTE] Required Go version more than 1.9
```
go get -u github.com/knocknote/vitess-sqlparser
```# Examples
```go
package mainimport (
"fmt"
"github.com/blastrain/vitess-sqlparser/sqlparser"
)func main() {
stmt, err := sqlparser.Parse("select * from user_items where user_id=1 order by created_at limit 3 offset 10")
if err != nil {
panic(err)
}
fmt.Printf("stmt = %+v\n", stmt)
}```