Coder Social home page Coder Social logo

schemabuf's Introduction

schemabuf

GoDoc

Generates a protobuf schema from your mysql database schema.

Uses

Use from the command line:

go install github.com/mcos/schemabuf

$ schemabuf -h

Usage of schemabuf:
  -db string
        the database type (default "mysql")
  -host string
        the database host (default "localhost")
  -ignore_tables string
        a comma spaced list of tables to ignore
  -package string
        the protocol buffer package. defaults to the database schema. (default "db_name")
  -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")
$ schemabuf -host my.database.com -port 3307 -user foo -schema bar -package my_package -ignore_tables=billing,passwords > foobar.proto

Use as an imported library

import "github.com/mcos/schemabuf"

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

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

    defer db.Close()

    s, err := schemabuf.GenerateSchema(db, pkg, nil)

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

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

schemabuf's People

Contributors

mcos avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

schemabuf's Issues

hi,i got an question for golang project.

language: golang
i generate proto file . contain text as follow:
google.protobuf.Timestamp create_time = 19;
google.protobuf.Timestamp update_time = 20;

but when i build my golang project. can.'t find
*protobuf.Timestamp this type. the reason is that author of this repositor can't exist go file from protoFile.
How can I solve this problem?
----- i use ci-cd,so it's not good by Manually generating

Skip/discard singularize message name (table name)

If I have 2 tables with similar names, eg: some_type and some_types, then I get only one message named SomeType, with all fields are merged from 2 tables above.

Obviously, some errors like schema.proto:6176:9: "id" is already defined in "schema.SomeType". occurred when I used it with protoc command.

hi,i got an question about golang.

language: golang
i generate proto file . contain text as follow:
google.protobuf.Timestamp create_time = 19;
google.protobuf.Timestamp update_time = 20;

but when i build my golang project. can.'t find
*protobuf.Timestamp this type. the reason is that author of this repositor can't exist go file from protoFile.
How can I solve this problem?
----- i use ci-cd,so it's not good by Manually generating

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.