Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var DatabaseDsnMap = map[DBType]string{ DBTypeSQLite: "%s", DBTypeOracle: "%s/%s@%s:%d/%s", DBTypeMySQL: "%s:%s@tcp(%s:%d)/%s?parseTime=True&loc=Local&timeout=30s", DBTypePostgres: "user=%s password=%s host=%s port=%d dbname=%s sslmode=disable TimeZone=Asia/Shanghai", DBTypeSqlserver: "user id=%s;password=%s;server=%s;port=%d;database=%s;encrypt=disable", DBTypeGreenplum: "user=%s password=%s host=%s port=%d dbname=%s sslmode=disable TimeZone=Asia/Shanghai", }
DatabaseDsnMap 关系型数据库类型 username、password、address、port、dbname
View Source
var JDBCUrlMap = map[DBType]string{ DBTypeOracle: "jdbc:oracle:thin:@%s:%d/%s", DBTypeMySQL: "jdbc:mysql://%s:%d/%s?charset=utf8mb4&parseTime=True&loc=Local&timeout=30s", DBTypePostgres: "jdbc:postgresql://%s:%d/%s", DBTypeSqlserver: "jdbc:sqlserver://%s:%d;DatabaseName=%s;encrypt=disable", DBTypeGreenplum: "jdbc:postgresql://%s:%d/%s", }
JDBCUrlMap 关系型数据库类型 username、password、address、port、dbname
Functions ¶
func InitConfig ¶
Types ¶
type Config ¶
type Config struct { DBName string `json:"db_name"` // 数据库名称(要求唯一) JDBCUrl string `json:"jdbc_url"` // jdbc_url DSN string `json:"dsn"` // 数据库连接串 DBType DBType `json:"db_type"` Host string `json:"host"` Port int `json:"port"` User string `json:"user"` Password string `json:"password"` Database string `json:"database"` MaxOpenConn int `json:"max_open_conn"` // 最大连接数 MaxIdleConn int `json:"max_idle_conn"` // 最大空闲连接数 ConnMaxLifeTime time.Duration `json:"conn_max_life_time"` // 连接最大存活时间 SSLMode string `json:"ssl_mode"` TimeZone string `json:"time_zone"` Charset string `json:"charset"` }
Config Database configuration
func GetDBConfig ¶
func (*Config) GenJDBCUrl ¶
Click to show internal directories.
Click to hide internal directories.