feat: 18 引擎驱动全家桶 + 驱动管理/离线包 + 设置中心 + 工作台交互打磨
驱动接入(全部本机真实例验收): - Elasticsearch 原生 SQL API、InfluxDB 原生 HTTP+Flux(官方 JDBC 付费许可,实测弃用) - ZooKeeper/MongoDB JVM agent(连接时自动下载官方驱动 jar,sha256 钉版本到 ~/.opsxdb/drivers/) - 达梦 JDBC agent 桥就绪(待厂商 jar+实例);TiDB 真实例验收 - 协议族代码审查放行 PolarDB/TDSQL/OceanBase/Kingbase/GaussDB/Oracle - 驱动能力模型:按驱动开关对象树分组/右键菜单/行编辑,NoSQL 树拍平(对象直挂库节点) 驱动管理: - 驱动管理弹框(状态/预装/离线包导入/JDK 检测)+ /api/drivers/* 三接口 - opsxdb-driver 驱动商店仓库(清单/fetch.sh/pack.sh 离线包/import.sh) - 连接时懒加载:DMG 零 Java 产物,首连自动下载(实测 ZK 九件套 1.35s),离线包自动回退 UI/交互: - 设置中心(⚙):常规/执行/结果/驱动/快捷键/关于,左导航+右面板(对标 opsxshell) - 实例级展开箭头(行首 SVG chevron,替代字体回退失真的 Unicode 三角) - 树内嵌套渲染修复:对象树挂在激活连接下;工具栏窄窗口不断行(按钮 nowrap+整颗换行) - 侧栏连接行精简(图标+连接名)、SQLite SSH 守卫、Oracle 死参数清理 质量: - Go 协议层/离线回退单测、E2E 门控测试(ES/ZK/Influx/Mongo/TiDB/JDBC 桥) - 驱动注册表单一事实来源 connection-types.json,README/BACKLOG/AGENTS 同步
This commit is contained in:
1 parent
26f459d1b8
commit
a9510235bb
156 files changed
+17200
-2520
No files matched your search
@@ -1,12 +1,17 @@
|
||||
package db
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
_ "modernc.org/sqlite"
|
||||
)
|
||||
|
||||
// openSQLite 打开 SQLite 库文件;文件不存在时报错而非静默建空库。
|
||||
// DSN 追加 busy_timeout / foreign_keys pragma。
|
||||
func openSQLite(c ConnReq) (*sql.DB, error) {
|
||||
path := c.Database
|
||||
if path == "" {
|
||||
@@ -15,15 +20,37 @@ func openSQLite(c ConnReq) (*sql.DB, error) {
|
||||
if path == "" {
|
||||
return nil, fmt.Errorf("SQLite 需要 database 填文件路径")
|
||||
}
|
||||
return sql.Open("sqlite", path)
|
||||
dsn := path
|
||||
switch {
|
||||
case path == ":memory:":
|
||||
// 统一走 file: URI 以便携带 _pragma 参数
|
||||
dsn = "file::memory:"
|
||||
case strings.HasPrefix(path, "file:"):
|
||||
// 调用方自带 URI 参数,不再做存在性检查
|
||||
default:
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
return nil, fmt.Errorf("SQLite 文件不存在: %s", path)
|
||||
}
|
||||
dsn = "file:" + path
|
||||
}
|
||||
sep := "?"
|
||||
if strings.Contains(dsn, "?") {
|
||||
sep = "&"
|
||||
}
|
||||
dsn += sep + "_pragma=busy_timeout(5000)&_pragma=foreign_keys(1)"
|
||||
return sql.Open("sqlite", dsn)
|
||||
}
|
||||
|
||||
func quoteSQLiteIdent(s string) string {
|
||||
return `"` + strings.ReplaceAll(s, `"`, `""`) + `"`
|
||||
}
|
||||
|
||||
func listDatabasesSQLite(_ *sql.DB) ([]string, error) {
|
||||
return []string{"main"}, nil
|
||||
}
|
||||
|
||||
func listTablesSQLite(db *sql.DB, _ string) ([]string, error) {
|
||||
rows, err := db.Query(`SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY 1`)
|
||||
func listTablesSQLite(ctx context.Context, db *sql.DB, _ string) ([]string, error) {
|
||||
rows, err := db.QueryContext(ctx, `SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%' ORDER BY 1`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -39,8 +66,8 @@ func listTablesSQLite(db *sql.DB, _ string) ([]string, error) {
|
||||
return out, rows.Err()
|
||||
}
|
||||
|
||||
func listColumnsSQLite(dbh *sql.DB, _, table string) ([]ColumnInfo, error) {
|
||||
rows, err := dbh.Query(`PRAGMA table_info(` + quotePGIdent(table) + `)`)
|
||||
func listColumnsSQLite(ctx context.Context, dbh *sql.DB, _, table string) ([]ColumnInfo, error) {
|
||||
rows, err := dbh.QueryContext(ctx, `PRAGMA table_info(`+quoteSQLiteIdent(table)+`)`)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user