master
xiexiaojun 6 years ago
parent 980c051da3
commit 6511a0be74

@ -3,7 +3,8 @@ package cmd
import (
"fmt"
"os"
"public/tools"
"github.com/xie1xiao1jun/public/tools"
"github.com/xie1xiao1jun/gorm-tools/data/config"
"github.com/xie1xiao1jun/gorm-tools/data/view/gtools"

@ -1,6 +1,29 @@
package gtools
import (
"fmt"
"github.com/xie1xiao1jun/gorm-tools/data/config"
"github.com/xie1xiao1jun/public/mysqldb"
)
//开始执行
func Execute() {
orm := mysqldb.OnInitDBOrm(config.GetMysqlConStr())
defer orm.OnDestoryDB()
//获取列名
var tables []string
rows, err := orm.Raw("show tables").Rows()
if err != nil {
fmt.Println(err)
}
defer rows.Close()
for rows.Next() {
var table string
rows.Scan(&table)
tables = append(tables, table)
}
fmt.Println(tables)
}

@ -1,8 +1,6 @@
package main
import (
"github.com/xie1xiao1jun/gorm-tools/data/cmd"
)
import "github.com/xie1xiao1jun/gorm-tools/data/cmd"
func main() {
cmd.Execute()

Loading…
Cancel
Save