mirror of
https://gitee.com/XM-GO/PandaX.git
synced 2026-04-28 10:09:37 +08:00
支持tdengine
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"github.com/XM-GO/PandaKit/cache"
|
||||
"pandax/apps/visual/entity"
|
||||
"pandax/pkg/global"
|
||||
"pandax/pkg/tool"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
@@ -74,6 +75,12 @@ func (di *DbInstance) GetMeta() DbMetadata {
|
||||
if dbType == entity.DbTypePostgres {
|
||||
return &PgsqlMetadata{di: di}
|
||||
}
|
||||
if dbType == entity.DbTypeTdengine {
|
||||
return &TDMetadata{di: di}
|
||||
}
|
||||
if dbType == entity.DbTypeClickHouse {
|
||||
return &ClickHouseMetadata{di: di}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -121,11 +128,10 @@ func AddDbInstanceToCache(id string, di *DbInstance) {
|
||||
|
||||
func TestConnection(d *entity.VisualDataSource) error {
|
||||
// 验证第一个库是否可以连接即可
|
||||
DB, err := GetDbConn(d)
|
||||
_, err := GetDbConn(d)
|
||||
if err != nil {
|
||||
return err
|
||||
} else {
|
||||
DB.Close()
|
||||
return nil
|
||||
}
|
||||
}
|
||||
@@ -138,8 +144,11 @@ func GetDbConn(d *entity.VisualDataSource) (*sql.DB, error) {
|
||||
DB, err = getMysqlDB(d)
|
||||
} else if d.SourceType == entity.DbTypePostgres {
|
||||
DB, err = getPgsqlDB(d)
|
||||
} else if d.SourceType == entity.DbTypeTdengine {
|
||||
DB, err = getTdDB(d)
|
||||
} else if d.SourceType == entity.DbTypeClickHouse {
|
||||
DB, err = getClickHouseDB(d)
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -148,7 +157,6 @@ func GetDbConn(d *entity.VisualDataSource) (*sql.DB, error) {
|
||||
DB.Close()
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return DB, nil
|
||||
}
|
||||
|
||||
@@ -195,6 +203,9 @@ func SelectDataByDb(db *sql.DB, selectSql string) ([]string, []map[string]interf
|
||||
if isFirst {
|
||||
colNames = append(colNames, colName)
|
||||
}
|
||||
if strings.Contains(colName, "_") {
|
||||
colName = tool.ToCamelCase(colName)
|
||||
}
|
||||
rowData[colName] = valueConvert(v, colType)
|
||||
}
|
||||
// 放入结果集
|
||||
|
||||
Reference in New Issue
Block a user