GithubHelp home page GithubHelp logo

pyjcode / generate Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jjggzz/generate

0.0 1.0 0.0 185 KB

golang mysql操作代码生成工具,采用sqlx作为操作库

Shell 1.28% Go 97.38% Batchfile 1.34%

generate's Introduction

generate

golang mysql数据操作层代码生成工具,采用sqlx作为操作库,在项目中想使用该工具需要为你的项目安装sqlx依赖:

# mysql驱动安装
go get -u github.com/go-sql-driver/mysql
# sqlx安装
go get -u github.com/jmoiron/sqlx

生成的代码结构如下

  repository
    -- demo_repository.go # 仓库

windows安装

1.执行wininstall.bat

  > wininstall.bat

会在%GOPATH%\go\bin目录下生成sqlxgen.exe

2.添加环境变量

将%GOPATH%\go\bin添加到环境变量

  # 查看帮助
  >sqlxgen.exe --help
  Usage of sqlxgen.exe:
  -db string
        db server name
  -ip string
        db server ip (default "127.0.0.1")
  -out string
        file output path (default "./")
  -p string
        db server password
  -pkg string
        go package name (default "repository")
  -port int
        db server port (default 3306)
  -u string
        db server username
  -table string
        if not specified generate all

linux安装

1.执行linuxinstall.sh

  > chmod 777 linuxinstall.sh
  > ./linuxinstall.sh

会在%GOPATH%/go/bin目录下生成sqlxgen

2.添加环境变量

将%GOPATH%/go/bin添加到环境变量

  # 查看帮助
  >sqlxgen --help
  Usage of sqlxgen:
  -db string
        db server name
  -ip string
        db server ip (default "127.0.0.1")
  -out string
        file output path (default "./")
  -p string
        db server password
  -pkg string
        go package name (default "repository")
  -port int
        db server port (default 3306)
  -u string
        db server username
  -table string
        if not specified generate all

使用

在你的项目路径下执行

# linux
> sqlxgen -u root -p 123456 -db dbname
# windows
> sqlxgen.exe -u root -p 123456 -db dbname

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.