Categorygithub.com/wangzhongyang/sql2proto
modulepackage
1.0.5
Repository: https://github.com/wangzhongyang/sql2proto.git
Documentation: pkg.go.dev

# README

What is sql2proto

In the work, the database is generally designed first, and then the proto file is written, and the proto file may contain objects of the table structure.

Because there is no related program found on the Internet, this program was developed

中文说明

sql2proto

There are three main features:

  1. Generate proto file from SQL file
  2. Generate proto file based on MySQL dsn and table name (single or multiple table names split with ',')
  3. Generate proto file from SQL statement

Getting started

Environments

go version
go version go1.18.10 darwin/amd64

Installation

go build github.com/wangzhongyang/sql2proto

Use

# Read SQL file to generate proto file
./sql2proto -o=/Users/wangzhongyang/go/src/sql2proto/example  -f=/Users/wangzhongyang/go/src/sql2proto/example/database.sql

# Connect to database to generate proto file
./sql2proto -o=/Users/wangzhongyang/go/src/sql2proto/example  -db-dsn="sql2proto:sql2proto@tcp(zhongyang.wang:3306)/sql2proto? charset=utf8mb4&parseTime=True&loc=Local" -db-table="test_table,test_table2"

proto generates go files

protoc --proto_path=./example --go_out=. ./example/gen.proto

License

Copyright [2023] wangzhongyang

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

 http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

# Packages

No description provided by the author
No description provided by the author