ホームページ  >  記事  >  データベース  >  Go xorm は mysql の構造例分析を生成します

Go xorm は mysql の構造例分析を生成します

WBOY
WBOY転載
2023-05-30 16:35:151553ブラウズ

インターネット上の多くのリソースでは、xorm reverse mysql "root:123456@tcp(127.0.0.1:3306)/users?charset=utf8" ./

実行後のエラー: 2022/03 /16 15:00:53 [エラー] reverse.go:196 UnknowncolType INT UNSIGNED

Go xorm は mysql の構造例分析を生成します

実際には、元の xorm はもう使用できません。使用しました。現在は次のようになります。

go get xorm.io/reverse

を実行し、GOPATH

## の下の bin ディレクトリに入ります。 Go xorm は mysql の構造例分析を生成します

# vicustom.yml、データベースに接続するための情報を構成するために使用されます:

kind: reverse
name: users
source:
  database: mysql
  conn_str: 'root:123456@tcp(127.0.0.1:3306)/users?parseTime=true'
targets:
- type: codes
  language: golang
  output_dir: ./testoutput

実行: ./reverse -fcustom.yml

次に、テスト出力を入力します。 /models.go を生成するディレクトリ ファイル:

package models

type UserInfo struct {
        Id         uint   `xorm:"not null pk autoincr comment('主键ID') UNSIGNED INT"`
        Name       string `xorm:"not null default '' comment('姓名') VARCHAR(50)"`
        Avatar     string `xorm:"not null default '' comment('头像') VARCHAR(255)"`
        Birthday   string `xorm:"not null default '' comment('出生日期') VARCHAR(50)"`
        Sex        int    `xorm:"not null default 0 comment('性别:0未知,1男,2女') TINYINT(1)"`
        City       string `xorm:"not null default '' comment('所在城市') VARCHAR(50)"`
        Introduce  string `xorm:"comment('自我介绍') TEXT"`
        Status     int    `xorm:"not null default 0 comment('状态:0正常,1禁用') TINYINT(1)"`
        CreateTime uint   `xorm:"not null default 0 comment('创建时间') UNSIGNED INT"`
        UpdateTime uint   `xorm:"not null default 0 comment('最后修改时间') UNSIGNED INT"`
        DeleteTime uint   `xorm:"not null default 0 comment('删除时间') UNSIGNED INT"`
}

Go xorm は mysql の構造例分析を生成します

以上がGo xorm は mysql の構造例分析を生成しますの詳細内容です。詳細については、PHP 中国語 Web サイトの他の関連記事を参照してください。

声明:
この記事はyisu.comで複製されています。侵害がある場合は、admin@php.cn までご連絡ください。