MySQL 结构转 protobuf 模型 schemabuf

码农软件 · 软件分类 · 常用工具包 · 2019-08-14 17:41:30

软件介绍

schemabuf 可以根据 MySQL 的表结构来生成 ProtocolBuffers 对应的模型。

使用方法:

$ schemabuf -h

Usage of schemabuf:
  -db string
        the database type (default "mysql")
  -host string
        the database host (default "localhost")
  -password string
        the database password (default "root")
  -port int
        the database port (default 3306)
  -schema string
        the database schema (default "db_name")
  -user string
        the database user (default "root")

Go 语言调用:

import "github.com/mcos/schemabuf"

func main() {
    connStr := config.get("dbConnStr")

    db, err := sql.Open(*dbType, connStr)
    if err != nil {
        log.Fatal(err)
    }

    defer db.Close()

    s, err := schemabuf.GenerateSchema(db)

    if nil != err {
        log.Fatal(err)
    }

    if nil != s {
        fmt.Println(s)
    }
}

本文地址:https://codercto.com/soft/d/12363.html

动画的时间掌握

动画的时间掌握

哈罗德•威特克、约翰•哈拉斯 / 中国电影出版社 / 2012-7-1 / 38.00元

动画的时间掌握(修订版),ISBN:9787106035334,作者:(英)哈罗德·威特克 等著一起来看看 《动画的时间掌握》 这本书的介绍吧!

JSON 在线解析
JSON 在线解析

在线 JSON 格式化工具

MD5 加密
MD5 加密

MD5 加密工具

html转js在线工具
html转js在线工具

html转js在线工具