Giter Club home page Giter Club logo

xsqlparser's Introduction

xSqlParser

Parse SQL statements, support mysql, oracle, sqlserver,sql92

The first open source project of a golang novice, welcome to star, fork, if you have any needs, comments and suggestions, please mention them in the issue, I can also use antlr's TokenStreamRewrite to make logical changes to specific nodes of sql, and the project is still temporarily This feature was not added, I can add it if needed.

DOCUMENTATION📜


EN doc CN doc

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Installing

Get it

go get github.com/jiunx/xsqlparser

Running the tests

You can use the test code in parser_test.go to test that the parser parses the sql statement correctly.

    sql := "select id,name,address from t"
    parserFactory := parser.GetParserFactoryInstance()
    mysqlParser, err := parserFactory.GetParser(util.Mysql)
    if err != nil {
        fmt.Println(err)
        return
    }
    statement, err2 := mysqlParser.Parse(context.Background(), sql)
    if err2 != nil {
        fmt.Println(err2)
    }
    fmt.Printf("%+v\n", statement)

You will get output like this


    &{Sql:select id,name,address from t SqlType:select Language:mysql Tables:[t] Columns:[id name address] Results:[id name address] Ast:0xc000246c00}

The following describes the structure of the statement


statement.SqlType is the sql type, such as select, insert, update, delete, create, drop, etc.

statement.Tables is the table name, such as t.

statement.Columns is the column name, such as id, name, address.

statement.Results is the resultset, such as id, name, address.

statement.Ast This sql AST tree, if you are familiar with ANTLR or tree operations, you can also use listener to parse sql.
.

Contributing

jiunx, I am the author of this project.

antlr, mainly rely on technology

shardingsphere,the grammer file of antlr is obtained from here

Authors

jiunx

Acknowledgments

  • Antlr4

xsqlparser's People

Contributors

jiunx avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.