You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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
package main
import (
"fmt""github.com/blastrain/vitess-sqlparser/sqlparser"
)
funcmain() {
stmt, err:=sqlparser.Parse("select * from user_items where user_id=1 order by created_at limit 3 offset 10")
iferr!=nil {
panic(err)
}
fmt.Printf("stmt = %+v\n", stmt)
}
About
simply SQL Parser for Go ( powered by vitess and TiDB )