db

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2022 License: BSD-2-Clause Imports: 9 Imported by: 0

README

数据库连接 支持Oracle/PostgreSQL/MySQL

配置文件示例:

"MainDB": {
	"Name": "核心库",
	"Protocol": "MySQL",   # 目前可选MySQL/Oracle/PostgreSQL/PGSQL
	"IP": "10.242.31.180", # 必填
	"Port": "3306",        # 必填
	"DBName": "hibss",     # 必填
	"Network": "tcp",      # tcp/udp...
	"UserName": "hibss",   # 
	"PassWord": "Hibss135!",
	"NLS_LANG": "SIMPLIFIED CHINESE_CHINA.ZHS16GBK"
}

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DBCfg

type DBCfg struct {
	Name        string        `json:"Name"`
	Protocol    string        `json:"Protocol"`
	IP          string        `json:"IP"`
	Port        string        `json:"Port"`
	DBName      string        `json:"DBName"`
	Network     string        `json:"Network"`
	UserName    string        `json:"UserName"`
	PassWord    string        `json:"PassWord"`
	NlsLang     string        `json:"NlsLang"`
	LibDir      string        `json:"LibDir"`
	MaxOpen     int           `json:"MaxOpen"`
	MaxIdle     int           `json:"MaxIdle"`
	MaxLifetime time.Duration `json:"MaxLifetime"`
}

type DBConn

type DBConn struct {
	*sql.DB
	*DBCfg
}

func NewDBConn

func NewDBConn(dbcfg DBCfg) *DBConn

New

func (*DBConn) Connect

func (conn *DBConn) Connect() error

Jump to

Keyboard shortcuts

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