dbmcli

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 20, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package dbmcli 是对外暴露的稳定高层 API(Facade)。

它封装 internal/driver 与 internal/config 的常用组合, 让外部 Go 程序或集成测试能以最小代价使用 dbm 的能力, 而不必直接依赖 internal 包(Go 的 internal 机制禁止跨模块访问)。

用法示例:

cfg := &dbm.Datasource{
    Type:        "oracle",
    Host:        "10.0.0.1", Port: 1521,
    ServiceName: "ORCLPDB1", User: "ro", Password: os.Getenv("PWD"),
}
conn, err := dbm.Open(ctx, cfg)
...
rows, _ := conn.Metadata().Tables(ctx, "HR")

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn = driver.Conn

Conn 是 internal.driver.Conn 的对外别名。

func Open

func Open(ctx context.Context, ds *Datasource) (Conn, func(), error)

Open 依据 Datasource 配置打开连接(带写守卫)。

func OpenFromConfigFile

func OpenFromConfigFile(ctx context.Context, configPath, datasource string) (Conn, func(), error)

OpenFromConfigFile 从 dbm 配置文件按名称打开数据源。

type Datasource

type Datasource struct {
	Type         string
	Host         string
	Port         int
	User         string
	Password     string
	Database     string // MySQL 等的数据库名
	TLS          string // 可选 TLS:skip-verify / true / 自定义
	ServiceName  string // Oracle
	SID          string // Oracle
	AllowWrite   bool
	ForceVersion string
	FetchSize    int
	MaxOpenConns int
	MaxIdleConns int
}

Datasource 是对外暴露的数据源配置(internal 类型的稳定投影)。

type MetadataProvider

type MetadataProvider = driver.MetadataProvider

MetadataProvider 是对外别名。

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL