support sqlite
支持sqlite
This commit is contained in:
@@ -40,6 +40,7 @@ var TypeMysqlDicMp = map[string]string{
|
||||
"blob": "[]byte",
|
||||
"mediumblob": "[]byte",
|
||||
"longblob": "[]byte",
|
||||
"integer": "int64",
|
||||
}
|
||||
|
||||
// TypeMysqlMatchMp Fuzzy Matching Types.模糊匹配类型
|
||||
@@ -58,6 +59,7 @@ var TypeMysqlMatchMp = map[string]string{
|
||||
`^(enum)[(](.)+[)]`: "string",
|
||||
`^(varchar)[(]\d+[)]`: "string",
|
||||
`^(varbinary)[(]\d+[)]`: "[]byte",
|
||||
`^(blob)[(]\d+[)]`: "[]byte",
|
||||
`^(binary)[(]\d+[)]`: "[]byte",
|
||||
`^(decimal)[(]\d+,\d+[)]`: "float64",
|
||||
`^(mediumint)[(]\d+[)]`: "string",
|
||||
@@ -66,4 +68,6 @@ var TypeMysqlMatchMp = map[string]string{
|
||||
`^(float)[(]\d+,\d+[)] unsigned`: "float64",
|
||||
`^(datetime)[(]\d+[)]`: "time.Time",
|
||||
`^(bit)[(]\d+[)]`: "[]uint8",
|
||||
`^(text)[(]\d+[)]`: "string",
|
||||
`^(integer)[(]\d+[)]`: "int",
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package gtools
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os/exec"
|
||||
|
||||
"github.com/xxjwxc/public/mylog"
|
||||
@@ -11,6 +12,7 @@ import (
|
||||
"github.com/xxjwxc/gormt/data/config"
|
||||
|
||||
"github.com/xxjwxc/gormt/data/view/model/genmysql"
|
||||
"github.com/xxjwxc/gormt/data/view/model/gensqlite"
|
||||
"github.com/xxjwxc/public/tools"
|
||||
)
|
||||
|
||||
@@ -28,8 +30,20 @@ func showCmd() {
|
||||
// tt.Nickname = "ticket_001"
|
||||
// orm.Where("nickname = ?", "ticket_001").Find(&tt)
|
||||
// fmt.Println(tt)
|
||||
modeldb := genmysql.GetMysqlModel()
|
||||
var modeldb model.IModel
|
||||
switch config.GetDbInfo().Type {
|
||||
case 0:
|
||||
modeldb = genmysql.GetModel()
|
||||
case 1:
|
||||
modeldb = gensqlite.GetModel()
|
||||
}
|
||||
if modeldb == nil {
|
||||
mylog.Error(fmt.Errorf("modeldb not fund : please check db_info.type (0:mysql , 1:sqlite , 2:mssql) "))
|
||||
return
|
||||
}
|
||||
|
||||
pkg := modeldb.GenModel()
|
||||
// gencnf.GenOutPut(&pkg)
|
||||
// just for test
|
||||
// out, _ := json.Marshal(pkg)
|
||||
// tools.WriteFile("test.txt", []string{string(out)}, true)
|
||||
|
||||
103
data/view/model/gencnf/gencnf.go
Normal file
103
data/view/model/gencnf/gencnf.go
Normal file
@@ -0,0 +1,103 @@
|
||||
package gencnf
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path"
|
||||
"strings"
|
||||
|
||||
"gopkg.in/yaml.v3"
|
||||
|
||||
"github.com/xxjwxc/gormt/data/config"
|
||||
"github.com/xxjwxc/gormt/data/view/model"
|
||||
"github.com/xxjwxc/public/mylog"
|
||||
"github.com/xxjwxc/public/tools"
|
||||
)
|
||||
|
||||
// GetCnfModel get model interface. 获取model接口
|
||||
func GetCnfModel() model.IModel {
|
||||
//now just support mysql
|
||||
return &CnfModel
|
||||
}
|
||||
|
||||
// GenOutPut 输出
|
||||
func GenOutPut(info *model.DBInfo) {
|
||||
path := path.Join(config.GetOutDir(), info.DbName+".yml")
|
||||
out, _ := yaml.Marshal(info)
|
||||
|
||||
flag := os.O_CREATE | os.O_WRONLY | os.O_TRUNC
|
||||
f, err := os.OpenFile(path, flag, 0666)
|
||||
if err != nil {
|
||||
mylog.Error(err)
|
||||
return
|
||||
}
|
||||
defer f.Close()
|
||||
f.Write(out)
|
||||
}
|
||||
|
||||
// CnfModel yaml model from IModel
|
||||
var CnfModel cnfModel
|
||||
|
||||
type cnfModel struct {
|
||||
}
|
||||
|
||||
// GenModel get model.DBInfo info.获取数据库相关属性
|
||||
func (m *cnfModel) GenModel() model.DBInfo {
|
||||
var dbInfo model.DBInfo
|
||||
// getPackageInfo(orm, &dbInfo)
|
||||
// 添加逻辑
|
||||
dbInfo.PackageName = m.GetPkgName()
|
||||
dbInfo.DbName = m.GetDbName()
|
||||
return dbInfo
|
||||
}
|
||||
|
||||
// GetDbName get database name.获取数据库名字
|
||||
func (m *cnfModel) GetDbName() string {
|
||||
dir := config.GetDbInfo().Host
|
||||
dir = strings.Replace(dir, "\\", "/", -1)
|
||||
if len(dir) > 0 {
|
||||
if dir[len(dir)-1] == '/' {
|
||||
dir = dir[:(len(dir) - 1)]
|
||||
}
|
||||
}
|
||||
var dbName string
|
||||
list := strings.Split(dir, "/")
|
||||
if len(list) > 0 {
|
||||
dbName = list[len(list)-1]
|
||||
}
|
||||
list = strings.Split(dbName, ".")
|
||||
if len(list) > 0 {
|
||||
dbName = list[0]
|
||||
}
|
||||
|
||||
if len(dbName) == 0 || dbName == "." {
|
||||
panic(fmt.Sprintf("%v : db host config err.must file dir", dbName))
|
||||
}
|
||||
|
||||
return dbName
|
||||
}
|
||||
|
||||
// GetPkgName package names through config outdir configuration.通过config outdir 配置获取包名
|
||||
func (m *cnfModel) GetPkgName() string {
|
||||
dir := config.GetOutDir()
|
||||
dir = strings.Replace(dir, "\\", "/", -1)
|
||||
if len(dir) > 0 {
|
||||
if dir[len(dir)-1] == '/' {
|
||||
dir = dir[:(len(dir) - 1)]
|
||||
}
|
||||
}
|
||||
var pkgName string
|
||||
list := strings.Split(dir, "/")
|
||||
if len(list) > 0 {
|
||||
pkgName = list[len(list)-1]
|
||||
}
|
||||
|
||||
if len(pkgName) == 0 || pkgName == "." {
|
||||
list = strings.Split(tools.GetModelPath(), "/")
|
||||
if len(list) > 0 {
|
||||
pkgName = list[len(list)-1]
|
||||
}
|
||||
}
|
||||
|
||||
return pkgName
|
||||
}
|
||||
@@ -47,8 +47,8 @@ func fixForeignKey(list []genForeignKey, columuName string, result *[]model.Fore
|
||||
}
|
||||
}
|
||||
|
||||
// GetMysqlModel get model interface. 获取model接口
|
||||
func GetMysqlModel() model.IModel {
|
||||
// GetModel get model interface. 获取model接口
|
||||
func GetModel() model.IModel {
|
||||
//now just support mysql
|
||||
return &MySQLModel
|
||||
}
|
||||
|
||||
@@ -23,7 +23,7 @@ func (m *mysqlModel) GenModel() model.DBInfo {
|
||||
defer orm.OnDestoryDB()
|
||||
|
||||
var dbInfo model.DBInfo
|
||||
getPackageInfo(orm, &dbInfo)
|
||||
m.getPackageInfo(orm, &dbInfo)
|
||||
dbInfo.PackageName = m.GetPkgName()
|
||||
dbInfo.DbName = m.GetDbName()
|
||||
return dbInfo
|
||||
@@ -31,7 +31,7 @@ func (m *mysqlModel) GenModel() model.DBInfo {
|
||||
|
||||
// GetDbName get database name.获取数据库名字
|
||||
func (m *mysqlModel) GetDbName() string {
|
||||
return config.GetMysqlDbInfo().Database
|
||||
return config.GetDbInfo().Database
|
||||
}
|
||||
|
||||
// GetPkgName package names through config outdir configuration.通过config outdir 配置获取包名
|
||||
@@ -59,8 +59,8 @@ func (m *mysqlModel) GetPkgName() string {
|
||||
return pkgName
|
||||
}
|
||||
|
||||
func getPackageInfo(orm *mysqldb.MySqlDB, info *model.DBInfo) {
|
||||
tabls := getTables(orm) // get table and notes
|
||||
func (m *mysqlModel) getPackageInfo(orm *mysqldb.MySqlDB, info *model.DBInfo) {
|
||||
tabls := m.getTables(orm) // get table and notes
|
||||
// if m := config.GetTableList(); len(m) > 0 {
|
||||
// // 制定了表之后
|
||||
// newTabls := make(map[string]string)
|
||||
@@ -94,7 +94,7 @@ func getPackageInfo(orm *mysqldb.MySqlDB, info *model.DBInfo) {
|
||||
}
|
||||
|
||||
// build element.构造元素
|
||||
tab.Em = getTableElement(orm, tabName)
|
||||
tab.Em = m.getTableElement(orm, tabName)
|
||||
// --------end
|
||||
|
||||
info.TabList = append(info.TabList, tab)
|
||||
@@ -106,7 +106,7 @@ func getPackageInfo(orm *mysqldb.MySqlDB, info *model.DBInfo) {
|
||||
}
|
||||
|
||||
// getTableElement Get table columns and comments.获取表列及注释
|
||||
func getTableElement(orm *mysqldb.MySqlDB, tab string) (el []model.ColumnsInfo) {
|
||||
func (m *mysqlModel) getTableElement(orm *mysqldb.MySqlDB, tab string) (el []model.ColumnsInfo) {
|
||||
keyNameCount := make(map[string]int)
|
||||
KeyColumnMp := make(map[string][]keys)
|
||||
// get keys
|
||||
@@ -133,7 +133,7 @@ func getTableElement(orm *mysqldb.MySqlDB, tab string) (el []model.ColumnsInfo)
|
||||
var foreignKeyList []genForeignKey
|
||||
if config.GetIsForeignKey() {
|
||||
sql := fmt.Sprintf(`select table_schema as table_schema,table_name as table_name,column_name as column_name,referenced_table_schema as referenced_table_schema,referenced_table_name as referenced_table_name,referenced_column_name as referenced_column_name
|
||||
from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where table_schema = '%v' AND REFERENCED_TABLE_NAME IS NOT NULL AND TABLE_NAME = '%v'`, config.GetMysqlDbInfo().Database, tab)
|
||||
from INFORMATION_SCHEMA.KEY_COLUMN_USAGE where table_schema = '%v' AND REFERENCED_TABLE_NAME IS NOT NULL AND TABLE_NAME = '%v'`, m.GetDbName(), tab)
|
||||
orm.Raw(sql).Scan(&foreignKeyList)
|
||||
}
|
||||
// ------------------end
|
||||
@@ -189,7 +189,7 @@ func getTableElement(orm *mysqldb.MySqlDB, tab string) (el []model.ColumnsInfo)
|
||||
}
|
||||
|
||||
// getTables Get columns and comments.获取表列及注释
|
||||
func getTables(orm *mysqldb.MySqlDB) map[string]string {
|
||||
func (m *mysqlModel) getTables(orm *mysqldb.MySqlDB) map[string]string {
|
||||
tbDesc := make(map[string]string)
|
||||
|
||||
// Get column names.获取列名
|
||||
@@ -212,7 +212,7 @@ func getTables(orm *mysqldb.MySqlDB) map[string]string {
|
||||
rows.Close()
|
||||
|
||||
// Get table annotations.获取表注释
|
||||
rows1, err := orm.Raw("SELECT TABLE_NAME,TABLE_COMMENT FROM information_schema.TABLES WHERE table_schema= '" + config.GetMysqlDbInfo().Database + "'").Rows()
|
||||
rows1, err := orm.Raw("SELECT TABLE_NAME,TABLE_COMMENT FROM information_schema.TABLES WHERE table_schema= '" + m.GetDbName() + "'").Rows()
|
||||
if err != nil {
|
||||
if !config.GetIsGUI() {
|
||||
fmt.Println(err)
|
||||
|
||||
74
data/view/model/gensqlite/common.go
Normal file
74
data/view/model/gensqlite/common.go
Normal file
@@ -0,0 +1,74 @@
|
||||
package gensqlite
|
||||
|
||||
import (
|
||||
"strings"
|
||||
|
||||
"github.com/xxjwxc/gormt/data/config"
|
||||
|
||||
"github.com/xxjwxc/gormt/data/view/model"
|
||||
)
|
||||
|
||||
// filterModel filter.过滤 gorm.Model
|
||||
func filterModel(list *[]genColumns) bool {
|
||||
if config.GetDBTag() != "gorm" {
|
||||
return false
|
||||
}
|
||||
|
||||
var _temp []genColumns
|
||||
num := 0
|
||||
for _, v := range *list {
|
||||
if strings.EqualFold(v.Name, "id") ||
|
||||
strings.EqualFold(v.Name, "created_at") ||
|
||||
strings.EqualFold(v.Name, "updated_at") ||
|
||||
strings.EqualFold(v.Name, "deleted_at") {
|
||||
num++
|
||||
} else {
|
||||
_temp = append(_temp, v)
|
||||
}
|
||||
}
|
||||
|
||||
if num >= 4 {
|
||||
*list = _temp
|
||||
return true
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// fixForeignKey fix foreign key.过滤外键
|
||||
func fixForeignKey(list []genForeignKey, columuName string, result *[]model.ForeignKey) {
|
||||
for _, v := range list {
|
||||
if strings.EqualFold(v.ColumnName, columuName) { // find it .找到了
|
||||
*result = append(*result, model.ForeignKey{
|
||||
TableName: v.ReferencedTableName,
|
||||
ColumnName: v.ReferencedColumnName,
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// GetModel get model interface. 获取model接口
|
||||
func GetModel() model.IModel {
|
||||
//now just support mysql
|
||||
return &SQLiteModel
|
||||
}
|
||||
|
||||
// FixElementNote 分析元素表注释
|
||||
func FixElementNote(em *model.ColumnsInfo, note string) {
|
||||
matches := noteRegex.FindStringSubmatch(note)
|
||||
if len(matches) < 2 {
|
||||
em.Notes = note
|
||||
return
|
||||
}
|
||||
em.Notes = note[len(matches[0]):]
|
||||
|
||||
list := strings.Split(matches[1], ";")
|
||||
for _, v := range list {
|
||||
tmp := strings.Split(v, ":")
|
||||
if len(tmp) == 2 {
|
||||
if strings.EqualFold(tmp[0], "default") { // 默认值
|
||||
em.Default = tmp[1]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
31
data/view/model/gensqlite/def.go
Normal file
31
data/view/model/gensqlite/def.go
Normal file
@@ -0,0 +1,31 @@
|
||||
package gensqlite
|
||||
|
||||
import "regexp"
|
||||
|
||||
type keys struct {
|
||||
NonUnique int `gorm:"column:Non_unique"`
|
||||
KeyName string `gorm:"column:Key_name"`
|
||||
ColumnName string `gorm:"column:Column_name"`
|
||||
}
|
||||
|
||||
// genColumns show full columns
|
||||
type genColumns struct {
|
||||
Name string `gorm:"column:name"`
|
||||
Type string `gorm:"column:type"`
|
||||
Pk int `gorm:"column:pk"`
|
||||
NotNull int `gorm:"column:notnull"`
|
||||
}
|
||||
|
||||
//select table_schema,table_name,column_name,referenced_table_schema,referenced_table_name,referenced_column_name from INFORMATION_SCHEMA.KEY_COLUMN_USAGE
|
||||
// where table_schema ='matrix' AND REFERENCED_TABLE_NAME IS NOT NULL AND TABLE_NAME = 'credit_card' ;
|
||||
// genForeignKey Foreign key of db info . 表的外键信息
|
||||
type genForeignKey struct {
|
||||
TableSchema string `gorm:"column:table_schema"` // Database of columns.列所在的数据库
|
||||
TableName string `gorm:"column:table_name"` // Data table of column.列所在的数据表
|
||||
ColumnName string `gorm:"column:column_name"` // Column names.列名
|
||||
ReferencedTableSchema string `gorm:"column:referenced_table_schema"` // The database where the index is located.该索引所在的数据库
|
||||
ReferencedTableName string `gorm:"column:referenced_table_name"` // Affected tables . 该索引受影响的表
|
||||
ReferencedColumnName string `gorm:"column:referenced_column_name"` // Which column of the affected table.该索引受影响的表的哪一列
|
||||
}
|
||||
|
||||
var noteRegex = regexp.MustCompile(`^\[@gormt\s(\S+)+\]`)
|
||||
197
data/view/model/gensqlite/gensqlite.go
Normal file
197
data/view/model/gensqlite/gensqlite.go
Normal file
@@ -0,0 +1,197 @@
|
||||
package gensqlite
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"sort"
|
||||
"strings"
|
||||
|
||||
"github.com/xxjwxc/public/mylog"
|
||||
|
||||
"github.com/jinzhu/gorm"
|
||||
_ "github.com/mattn/go-sqlite3"
|
||||
"github.com/xxjwxc/gormt/data/config"
|
||||
"github.com/xxjwxc/gormt/data/view/model"
|
||||
"github.com/xxjwxc/public/tools"
|
||||
)
|
||||
|
||||
// SQLiteModel mysql model from IModel
|
||||
var SQLiteModel sqliteModel
|
||||
|
||||
type sqliteModel struct {
|
||||
}
|
||||
|
||||
// GenModel get model.DBInfo info.获取数据库相关属性
|
||||
func (m *sqliteModel) GenModel() model.DBInfo {
|
||||
db, err := gorm.Open("sqlite3", config.GetDbInfo().Host)
|
||||
if err != nil {
|
||||
mylog.Error(err)
|
||||
return model.DBInfo{}
|
||||
}
|
||||
defer db.Close()
|
||||
|
||||
var dbInfo model.DBInfo
|
||||
m.getPackageInfo(db, &dbInfo)
|
||||
dbInfo.PackageName = m.GetPkgName()
|
||||
dbInfo.DbName = m.GetDbName()
|
||||
return dbInfo
|
||||
}
|
||||
|
||||
// GetDbName get database name.获取数据库名字
|
||||
func (m *sqliteModel) GetDbName() string {
|
||||
dir := config.GetDbInfo().Host
|
||||
dir = strings.Replace(dir, "\\", "/", -1)
|
||||
if len(dir) > 0 {
|
||||
if dir[len(dir)-1] == '/' {
|
||||
dir = dir[:(len(dir) - 1)]
|
||||
}
|
||||
}
|
||||
var dbName string
|
||||
list := strings.Split(dir, "/")
|
||||
if len(list) > 0 {
|
||||
dbName = list[len(list)-1]
|
||||
}
|
||||
list = strings.Split(dbName, ".")
|
||||
if len(list) > 0 {
|
||||
dbName = list[0]
|
||||
}
|
||||
|
||||
if len(dbName) == 0 || dbName == "." {
|
||||
panic(fmt.Sprintf("%v : db host config err.must file dir", dbName))
|
||||
}
|
||||
|
||||
return dbName
|
||||
}
|
||||
|
||||
// GetPkgName package names through config outdir configuration.通过config outdir 配置获取包名
|
||||
func (m *sqliteModel) GetPkgName() string {
|
||||
dir := config.GetOutDir()
|
||||
dir = strings.Replace(dir, "\\", "/", -1)
|
||||
if len(dir) > 0 {
|
||||
if dir[len(dir)-1] == '/' {
|
||||
dir = dir[:(len(dir) - 1)]
|
||||
}
|
||||
}
|
||||
var pkgName string
|
||||
list := strings.Split(dir, "/")
|
||||
if len(list) > 0 {
|
||||
pkgName = list[len(list)-1]
|
||||
}
|
||||
|
||||
if len(pkgName) == 0 || pkgName == "." {
|
||||
list = strings.Split(tools.GetModelPath(), "/")
|
||||
if len(list) > 0 {
|
||||
pkgName = list[len(list)-1]
|
||||
}
|
||||
}
|
||||
|
||||
return pkgName
|
||||
}
|
||||
|
||||
func (m *sqliteModel) getPackageInfo(orm *gorm.DB, info *model.DBInfo) {
|
||||
tabls := m.getTables(orm) // get table and notes
|
||||
for tabName, notes := range tabls {
|
||||
var tab model.TabInfo
|
||||
tab.Name = tabName
|
||||
tab.Notes = notes
|
||||
|
||||
if config.GetIsOutSQL() {
|
||||
// Get create SQL statements.获取创建sql语句
|
||||
rows, err := orm.Raw("SELECT tbl_name,sql FROM sqlite_master WHERE type='table' AND name = " + assemblyTable(tabName)).Rows()
|
||||
//defer rows.Close()
|
||||
if err == nil {
|
||||
if rows.Next() {
|
||||
var table, CreateTable string
|
||||
rows.Scan(&table, &CreateTable)
|
||||
tab.SQLBuildStr = CreateTable
|
||||
}
|
||||
}
|
||||
rows.Close()
|
||||
// ----------end
|
||||
}
|
||||
|
||||
// build element.构造元素
|
||||
tab.Em = m.getTableElement(orm, tabName)
|
||||
// --------end
|
||||
|
||||
info.TabList = append(info.TabList, tab)
|
||||
}
|
||||
// sort tables
|
||||
sort.Slice(info.TabList, func(i, j int) bool {
|
||||
return info.TabList[i].Name < info.TabList[j].Name
|
||||
})
|
||||
}
|
||||
|
||||
// getTableElement Get table columns and comments.获取表列及注释
|
||||
func (m *sqliteModel) getTableElement(orm *gorm.DB, tab string) (el []model.ColumnsInfo) {
|
||||
var list []genColumns
|
||||
// Get table annotations.获取表注释
|
||||
orm.Raw(fmt.Sprintf("PRAGMA table_info(%v)", assemblyTable(tab))).Scan(&list)
|
||||
// filter gorm.Model.过滤 gorm.Model
|
||||
if filterModel(&list) {
|
||||
el = append(el, model.ColumnsInfo{
|
||||
Type: "gorm.Model",
|
||||
})
|
||||
}
|
||||
// -----------------end
|
||||
|
||||
// ForeignKey
|
||||
var foreignKeyList []genForeignKey
|
||||
if config.GetIsForeignKey() {
|
||||
}
|
||||
// ------------------end
|
||||
|
||||
for _, v := range list {
|
||||
var tmp model.ColumnsInfo
|
||||
tmp.Name = v.Name
|
||||
tmp.Type = v.Type
|
||||
FixElementNote(&tmp, "")
|
||||
if v.Pk == 1 { // 主键
|
||||
tmp.Index = append(tmp.Index, model.KList{
|
||||
Key: model.ColumnsKeyPrimary,
|
||||
Multi: false,
|
||||
})
|
||||
}
|
||||
|
||||
tmp.IsNull = (v.NotNull != 1)
|
||||
|
||||
// ForeignKey
|
||||
fixForeignKey(foreignKeyList, tmp.Name, &tmp.ForeignKeyList)
|
||||
// -----------------end
|
||||
el = append(el, tmp)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// getTables Get columns and comments.获取表列及注释
|
||||
func (m *sqliteModel) getTables(orm *gorm.DB) map[string]string {
|
||||
tbDesc := make(map[string]string)
|
||||
|
||||
// Get column names.获取列名
|
||||
var tables []string
|
||||
|
||||
rows, err := orm.Raw("SELECT name FROM sqlite_master WHERE type='table'").Rows()
|
||||
if err != nil {
|
||||
if !config.GetIsGUI() {
|
||||
fmt.Println(err)
|
||||
}
|
||||
return tbDesc
|
||||
}
|
||||
|
||||
for rows.Next() {
|
||||
var table string
|
||||
rows.Scan(&table)
|
||||
if !strings.EqualFold(table, "sqlite_sequence") { // 剔除系统默认
|
||||
tables = append(tables, table)
|
||||
tbDesc[table] = ""
|
||||
}
|
||||
}
|
||||
rows.Close()
|
||||
|
||||
// TODO.获取表注释
|
||||
|
||||
return tbDesc
|
||||
}
|
||||
|
||||
func assemblyTable(name string) string {
|
||||
return "'" + name + "'"
|
||||
}
|
||||
Reference in New Issue
Block a user