GithubHelp home page GithubHelp logo

cctvbtx / go-codegen-yggdrasill Goto Github PK

View Code? Open in Web Editor NEW

This project forked from lpxxn/yggdrasill

0.0 0.0 0.0 299 KB

yggdrasill can turn the table into a go struct,support PostgreSQL, MySQL

License: GNU General Public License v3.0

Go 100.00%

go-codegen-yggdrasill's Introduction

中文简介
English

yggdrasill 把数据库的表转换成go语言的struct,支持 PostgreSQL, MySQL
eg:
generat model

安装

安装到GOPATHbin目录.

GO111MODULE=on go get -u github.com/lpxxn/yggdrasill/cmd/yggdrasill

帮助

yggdrasill -help 
Usage of yggdrasill:
  -dir string
        Destination dir for files generated. (default "./tmp")
  -dsn string
        dsn (default "postgresql")
  -package_name string
        package name default model. (default "model")
  -table_names value
        if it is empty, will generate all tables in database
  -target string
        mysql postgresql[pg] (default "postgresql")
  -template_path string
        custom template file path

命令

MySql

-targetmysql 默认生成数据库内的所有表

yggdrasill -target=mysql -dsn="root:123456@tcp(127.0.0.1:3306)/test" 

也可以生成指定表,使用 -table_names 指定想生成的表

yggdrasill -target=mysql -dsn="root:123456@tcp(127.0.0.1:3306)/test" -table_names=employee -table_names=user

PostgreSql

-targetpostgresql或者pg 默认生成数据库内的所有表

yggdrasill -target=pg -dsn="postgres://:@127.0.0.1:5432/test?sslmode=disable"

使用 -table_names 指定想生成的表

yggdrasill -target=pg -dsn="root:123456@tcp(127.0.0.1:3306)/test" -table_names=employee -table_names=user

自定义 template 使用 -template_path 自定义模板

yggdrasill  -target=pg -dsn="postgres://:@127.0.0.1:5432/test?sslmode=disable" -package_name=db_model -template_path=../../test/test_template.tml 

go-codegen-yggdrasill's People

Contributors

lpxxn 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.