GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — GitHub - go-sqlparser/sqlgparser: SQLite or SQL-92 Parser implemented in Go

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

197 Commits
197 Commits

Folders and files

NameName
Last commit message
Last commit date
dependency
dependency
 
 
.gitignore
.gitignore
 
 
.travis.yml
.travis.yml
 
 
CONTRIBUTORS.md
CONTRIBUTORS.md
 
 
LICENSE.md
LICENSE.md
 
 
Makefile
Makefile
 
 
README.md
README.md
 
 
analyzer.go
analyzer.go
 
 
analyzer_test.go
analyzer_test.go
 
 
ast.go
ast.go
 
 
ast_test.go
ast_test.go
 
 
comments.go
comments.go
 
 
comments_test.go
comments_test.go
 
 
encodable.go
encodable.go
 
 
encodable_test.go
encodable_test.go
 
 
impossible_query.go
impossible_query.go
 
 
normalizer.go
normalizer.go
 
 
normalizer_test.go
normalizer_test.go
 
 
parse_next_test.go
parse_next_test.go
 
 
parse_test.go
parse_test.go
 
 
parsed_query.go
parsed_query.go
 
 
parsed_query_test.go
parsed_query_test.go
 
 
precedence_test.go
precedence_test.go
 
 
redact_query.go
redact_query.go
 
 
redact_query_test.go
redact_query_test.go
 
 
sql.go
sql.go
 
 
sql.y
sql.y
 
 
token.go
token.go
 
 
token_test.go
token_test.go
 
 
tracked_buffer.go
tracked_buffer.go
 
 

Repository files navigation

sqlparser Report card GoDoc

Go package for parsing SQLite or SQL-92 queries.

Notice

The backbone of this repo is extracted from vitessio/vitess.

Inside vitessio/vitess there is a very nicely written sql parser. However as it's not a self-contained application, I created this one. It applies the same LICENSE as vitessio/vitess.

Usage

import (
    "github.com/CovenantSQL/sqlparser"
)

Then use:

sql := "SELECT * FROM table WHERE a = 'abc'"
stmt, err := sqlparser.Parse(sql)
if err != nil {
	// Do something with the err
}

// Otherwise do something with stmt
switch stmt := stmt.(type) {
case *sqlparser.Select:
	_ = stmt
case *sqlparser.Insert:
}

Alternative to read many queries from a io.Reader:

r := strings.NewReader("INSERT INTO table1 VALUES (1, 'a'); INSERT INTO table2 VALUES (3, 4);")

tokens := sqlparser.NewTokenizer(r)
for {
	stmt, err := sqlparser.ParseNext(tokens)
	if err == io.EOF {
		break
	}
	// Do something with stmt or err.
}

About

SQLite or SQL-92 Parser implemented in Go

Resources

Readme
Apache-2.0 license
Activity
Custom properties

Stars

2 stars

Watchers

0 watching

Forks

0 forks
Report repository

Releases

Packages

Used by

Contributors

Languages

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.