sqlparse/

directory
v0.0.0-...-9d95335 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 22, 2024 License: MIT

README

sqlparse

Simply SQL and DDL parser for Go (powered by vitess and TiDB ) this library inspired by https://github.com/xwb1989/sqlparser

forked from https://github.com/youtube/vitess/tree/master/go/vt/sqlparser

Why

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/sqlparser

Installation

go get github.com/bingoohuang/gg/pkg/sqlparse

Examples

package main

import (
	"fmt"
	"github.com/bingoohuang/gg/pkg/sqlparse/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)
}

Directories

Path Synopsis
Package hack gives you some efficient functionality at the cost of breaking some Go rules.
Package hack gives you some efficient functionality at the cost of breaking some Go rules.
Package sqltypes implements interfaces and types that represent SQL values.
Package sqltypes implements interfaces and types that represent SQL values.
tidbparser
ast
Package ast is the abstract syntax tree parsed from a SQL statement by parser.
Package ast is the abstract syntax tree parsed from a SQL statement by parser.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL