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 - CovenantSQL/sqlparser: SQLite or SQL-92 Parser implemented in Go

BranchesTags
Open more actions menu
 
 

Latest commit

 

History

224 Commits
224 Commits

Folders and files

NameName
Last commit message
Last commit date
.github/workflows
.github/workflows
 
 
dependency
dependency
 
 
.gitignore
.gitignore
 
 
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
 
 
go.mod
go.mod
 
 
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.

The module builds with Go 1.11 and later. Regenerating sql.go with make -B sql.go requires Go 1.17 or later for versioned go run support. The Makefile pins the generator that reproduces the committed parser byte for byte.

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

Topics

sql-92sql-parsersqlite3

Resources

Readme
Apache-2.0 license
Activity
Custom properties

Stars

18 stars

Watchers

1 watching

Forks

2 forks
Report repository

Releases

Packages

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.