Git Product home page Git Product logo

sql2struct's Introduction

Build Status Go Report Card GoDoc codecov License

sql2struct

mysql/postgresql database to golang struct for gorm model

install

go install github.com/starfishs/sql2struct@latest

usage

sql2struct --dsn="mysql://root:123456@tcp(localhost:3306)/test?charset=utf8mb4"

docker

docker run  -v /path/to/store:/workspace -w /workspace  starfishsfive/sql2struct:v1.0.0 --dsn="postgresql://root:123456@localhost:5432/test?sslmode=disable"

support

  • mysql
  • postgreSQL

Contributors

starfishs
Starfish
miajio
Snaro Chris Xiao
calabashbrother
Null

sql2struct's People

Contributors

calabashbrother avatar github-actions[bot] avatar miajio avatar starfishs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

sql2struct's Issues

Configurable capability assignment

MysqlType2GoType map in internal/mysql/sql.go file
The MysqlType2GoType value allows users to configure

for instance:
user need mysql data field type is bit(1), the bit(1) type is bool or other,
users can configure this type in the configuration file, as well as the structure or interface in the package matching this type and its corresponding code

and bug:
code in MysqlType2GoType["tinyint"] the go type is int8, if user sql use unsinged then go type is uint8
int int8 int32 int64 in sql default go type, is user sql use unsinged then type is uint uint8 uint32 uint64

how to use with postgresql

when i use with this command :sql2struct --dsn="postgresql://postgres:[email protected]:5432/icp" -o ./models

it report an error: error occur sql: unknown driver "postgresql" (forgotten import?)

i dontknow where i should install this driver

Proposal: Comand line variable tables should support regular expression

I would like to use -t *_order_info instead of -t a_order_info -t b_order_info -t c_order_info

For exmaple , When I want to use sql2struct among a few tables in the database.

I would type this cmd in the terminal:
sql2struct --dsn="root:12345678@tcp(localhost:3306)/test?charset=utf8mb4" -t a_order_info -t b_order_info -t c_order_info

what I expect is :
sql2struct --dsn="root:12345678@tcp(localhost:3306)/test?charset=utf8mb4" -t *_order_info

Thanks for your reading~

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.