Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsReadOnlySQL ¶
IsReadOnlySQL 做保守判定:默认拒绝;仅允许文档明确的只读语句。 解析失败/多语句时一律返回 false。
func RegisteredNames ¶
func RegisteredNames() []string
Types ¶
type ConnOptions ¶
type ConnOptions struct {
DSN string // 原生 DSN(优先级最高)
Host string
Port int
User string
Password string
Database string
Params map[string]string // 额外参数
Dialer Dialer // 自定义 dialer(如 SSH tunnel)
}
ConnOptions 是通用连接参数(由 config/CLI/ENV 合并而来)。
type Driver ¶
type Driver interface {
// Open 返回 *sql.DB;由具体 driver 实现连接参数解析。
Open(ctx context.Context, opts ConnOptions) (*sql.DB, *errors.XError)
}
Driver 是数据库驱动的最小抽象。
type QueryOptions ¶
type QueryOptions struct {
UnsafeAllowWrite bool // 允许写操作(绕过只读保护)
DBType string // 数据库类型:mysql 或 pg
}
QueryOptions 包含查询执行的选项。
type QueryResult ¶
type QueryResult struct {
Columns []string `json:"columns" yaml:"columns"`
Rows []map[string]any `json:"rows" yaml:"rows"`
}
QueryResult 是通用查询结果。
Click to show internal directories.
Click to hide internal directories.