mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-05-06 20:03:05 +08:00
- 实现基于原生 DOM 事件的零渲染列宽拖拽,彻底解决卡顿与误触排序问题 - 查询编辑器集成 DataGrid,支持 SQL 结果直接编辑与事务提交 - 侧边栏新增上下文感知的 "新建查询" 快捷入口 - 优化 TabManager 渲染逻辑与全局布局,消除不必要的滚动条
45 lines
1.3 KiB
Go
45 lines
1.3 KiB
Go
package db
|
|
|
|
import (
|
|
"fmt"
|
|
"GoNavi-Wails/internal/connection"
|
|
)
|
|
|
|
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
|
|
default:
|
|
// Default to MySQL for backward compatibility if empty
|
|
if dbType == "" {
|
|
return &MySQLDB{}, nil
|
|
}
|
|
return nil, fmt.Errorf("unsupported database type: %s", dbType)
|
|
}
|
|
}
|