Giter Site home page Giter Site logo

compilex's Introduction

compilex

配合daog组件的工具,可以把create table语句编译成daog需要的go代码

原理

基于mysql sql语句解析器解析出create table语句,遍历出表名、字段名、字段类型,字段是否为自增长,然后生成对应的go代码文件。 生成两个文件:

  • 主文件,开发者不能修改,包括表所对应的go struct、元数据、记录表字段名的匿名struct对象
  • 扩展文件,开发者可以修改、扩展,尤其是分表规则函数需要在init函数中设置

sql解析使用tidb/parser包

编译代码

运行build文件夹下的脚本

编译sql

./compilex -i="sql file" -pkg packageName -o xxx/xx

compilex's People

Contributors

rolandhe avatar

Stargazers

 avatar Yang Liu avatar

Watchers

 avatar

Forkers

smarticle

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.