Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AddConnection ¶
func AddConnection(config *Config, conn Connection) error
AddConnection 添加数据库连接
func DeleteConnection ¶
DeleteConnection 删除数据库连接
Types ¶
type Config ¶
type Config struct {
Connections []Connection `toml:"connections"` // 数据库连接列表
}
Config 配置文件结构
type Connection ¶
type Connection struct {
Name string `toml:"name"` // 连接名称
Type string `toml:"type"` // 数据库类型:mysql,postgres,sqlite
Host string `toml:"host"` // 主机地址
Port int `toml:"port"` // 端口号
User string `toml:"user"` // 用户名
Password string `toml:"password"` // 密码
DbName string `toml:"dbname"` // 数据库名称
FilePath string `toml:"filepath"` // SQLite文件路径
SSLMode string `toml:"sslmode"` // PostgreSQL SSL 模式:disable/require/verify-ca/verify-full,留空默认 disable
}
Connection 数据库连接配置
func GetConnectionByName ¶
func GetConnectionByName(config *Config, name string) (*Connection, error)
GetConnectionByName 根据名称获取数据库连接
Click to show internal directories.
Click to hide internal directories.