Skip to content

Commit

Permalink
config modify
Browse files Browse the repository at this point in the history
  • Loading branch information
fizzday committed Jan 26, 2018
1 parent 825d270 commit 3442fe2
Showing 1 changed file with 16 additions and 11 deletions.
27 changes: 16 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,21 +46,26 @@ import (
)

// DB Config.(Recommend to use configuration file to import)
var DbConfig = map[string]map[string]string{
"mysql_dev": {
"host": "localhost",
"username": "root",
"password": "",
"port": "3306",
"database": "test",
"charset": "utf8",
"protocol": "tcp",
"driver": "mysql", //DB driver
var DbConfig = map[string]interface{}{
"default": "mysql_dev", // 默认数据库配置
"SetMaxOpenConns": 300, // (连接池)最大打开的连接数,默认值为0表示不限制
"SetMaxIdleConns": 10, // (连接池)闲置的连接数, 默认1

"mysql_dev": map[string]string{// 定义名为 mysql_dev 的数据库配置
"host": "192.168.200.248", // 数据库地址
"username": "gcore", // 数据库用户名
"password": "gcore", // 数据库密码
"port": "3306", // 端口
"database": "test", // 链接的数据库名字
"charset": "utf8", // 字符集
"protocol": "tcp", // 链接协议
"prefix": "", // 表前缀
"driver": "mysql", // 数据库驱动(mysql,sqlite,postgres,oracle,mssql)
},
}

func main() {
db, err := gorose.Open(DbConfig, "mysql_dev")
db, err := gorose.Open(DbConfig)
if err != nil {
fmt.Println(err)
return
Expand Down

0 comments on commit 3442fe2

Please sign in to comment.