mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-05-12 04:09:40 +08:00
- 引入 TDengine 数据源能力并补齐运行时配置与标识符处理 - 侧栏对 schema.table 数据源统一展示短表名 - 表节点悬停显示完整 schema.table,降低重名识别成本 - 更新文档与验证用例,保证改动可追踪可回归
65 lines
1.7 KiB
Go
65 lines
1.7 KiB
Go
package db
|
|
|
|
import (
|
|
"GoNavi-Wails/internal/connection"
|
|
"fmt"
|
|
)
|
|
|
|
type Database interface {
|
|
Connect(config connection.ConnectionConfig) error
|
|
Close() error
|
|
Ping() error
|
|
Query(query string) ([]map[string]interface{}, []string, error)
|
|
Exec(query string) (int64, error)
|
|
GetDatabases() ([]string, error)
|
|
GetTables(dbName string) ([]string, error)
|
|
GetCreateStatement(dbName, tableName string) (string, error)
|
|
GetColumns(dbName, tableName string) ([]connection.ColumnDefinition, error)
|
|
GetAllColumns(dbName string) ([]connection.ColumnDefinitionWithTable, error)
|
|
GetIndexes(dbName, tableName string) ([]connection.IndexDefinition, error)
|
|
GetForeignKeys(dbName, tableName string) ([]connection.ForeignKeyDefinition, error)
|
|
GetTriggers(dbName, tableName string) ([]connection.TriggerDefinition, error)
|
|
}
|
|
|
|
type BatchApplier interface {
|
|
ApplyChanges(tableName string, changes connection.ChangeSet) error
|
|
}
|
|
|
|
// Factory
|
|
func NewDatabase(dbType string) (Database, error) {
|
|
switch dbType {
|
|
case "mysql":
|
|
return &MySQLDB{}, nil
|
|
case "postgres":
|
|
return &PostgresDB{}, nil
|
|
case "sqlite":
|
|
return &SQLiteDB{}, nil
|
|
case "oracle":
|
|
return &OracleDB{}, nil
|
|
case "dameng":
|
|
return &DamengDB{}, nil
|
|
case "kingbase":
|
|
return &KingbaseDB{}, nil
|
|
case "mongodb":
|
|
return &MongoDB{}, nil
|
|
case "sqlserver":
|
|
return &SqlServerDB{}, nil
|
|
case "highgo":
|
|
return &HighGoDB{}, nil
|
|
case "mariadb":
|
|
return &MariaDB{}, nil
|
|
case "vastbase":
|
|
return &VastbaseDB{}, nil
|
|
case "tdengine":
|
|
return &TDengineDB{}, nil
|
|
case "custom":
|
|
return &CustomDB{}, nil
|
|
default:
|
|
// Default to MySQL for backward compatibility if empty
|
|
if dbType == "" {
|
|
return &MySQLDB{}, nil
|
|
}
|
|
return nil, fmt.Errorf("unsupported database type: %s", dbType)
|
|
}
|
|
}
|