【问题标题】:How to get Description of MySQL Table in GoLang如何在 GoLang 中获取 MySQL 表的描述
【发布时间】:2017-05-06 21:19:30
【问题描述】:

com/jinzhu/gorm" 和 "github.com/go-sql-driver/mysql" 包与我的数据库交互并尝试获取表的描述但没有找到函数。请帮助

【问题讨论】:

    标签: go go-gorm


    【解决方案1】:

    使用gorm,您可以执行自定义查询并在struct中获取她的返回值,以下是如何显示表描述的示例:

    type Result struct {
        Field    string
        Type     string
        Null     string
        Key      string
        Default  string
        Extra    string
    }
    
    db.Raw("DESCRIBE TABLE_NAME").Scan(&result)
    

    按 gorm 查看更多: http://jinzhu.me/gorm/advanced.html#sql-builder

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多