master
xiexiaojun 6 years ago
parent 980c051da3
commit 6511a0be74

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

@ -1,6 +1,29 @@
package gtools package gtools
import (
"fmt"
"github.com/xie1xiao1jun/gorm-tools/data/config"
"github.com/xie1xiao1jun/public/mysqldb"
)
//开始执行 //开始执行
func Execute() { 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 package main
import ( import "github.com/xie1xiao1jun/gorm-tools/data/cmd"
"github.com/xie1xiao1jun/gorm-tools/data/cmd"
)
func main() { func main() {
cmd.Execute() cmd.Execute()

Loading…
Cancel
Save