feat(ReverseEngine):提交小优化,准备下班,回家弄
This commit is contained in:
+4
-2
@@ -8,6 +8,7 @@ import (
|
|||||||
"ReverseEngine/util"
|
"ReverseEngine/util"
|
||||||
"bufio"
|
"bufio"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
_ "github.com/go-sql-driver/mysql"
|
_ "github.com/go-sql-driver/mysql"
|
||||||
"gopkg.in/ini.v1"
|
"gopkg.in/ini.v1"
|
||||||
"log"
|
"log"
|
||||||
@@ -146,8 +147,9 @@ func dbReverse(path string, tableName string, dbName string, db *sql.DB) {
|
|||||||
if !result {
|
if !result {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
cms := util.FindColumnMessage(dbName, tableName, db) //查询数据库表字段信息
|
cms := util.FindColumnMessage(dbName, tableName, db) //查询数据库表字段信息
|
||||||
dErr := db.Close() //关闭数据库连接
|
tableComment := util.FindTableComment(dbName, tableName, db) //查询数据库表字段信息
|
||||||
|
dErr := db.Close() //关闭数据库连接
|
||||||
checkError(dErr, "数据库关闭失败:")
|
checkError(dErr, "数据库关闭失败:")
|
||||||
if nil == cms {
|
if nil == cms {
|
||||||
log.Println("没有查到数据库字段信息略过")
|
log.Println("没有查到数据库字段信息略过")
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ package util
|
|||||||
import (
|
import (
|
||||||
"ReverseEngine/entity"
|
"ReverseEngine/entity"
|
||||||
"database/sql"
|
"database/sql"
|
||||||
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -30,3 +31,24 @@ func FindColumnMessage(dbName string, tableName string, db *sql.DB) []entity.Col
|
|||||||
|
|
||||||
return cms
|
return cms
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FindTableComment(dbName string, tableName string, db *sql.DB) string {
|
||||||
|
|
||||||
|
sql := fmt.Sprintf("select table_comment from information_schema.tables where table_schema = '%s' and table_name ='%s'", dbName, tableName)
|
||||||
|
row, err := db.Query(sql)
|
||||||
|
if err != nil {
|
||||||
|
panic("数据库查询出错:" + err.Error())
|
||||||
|
}
|
||||||
|
fmt.Println(row)
|
||||||
|
var s string
|
||||||
|
for row.Next() {
|
||||||
|
err := row.Scan(&s)
|
||||||
|
if err != nil {
|
||||||
|
panic("字段赋值错误了" + err.Error())
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
break
|
||||||
|
}
|
||||||
|
|
||||||
|
return s
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user