Skip to content

Commit 2c9fa7d

Browse files
committed
str config improved
1 parent be6aa7a commit 2c9fa7d

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

connection.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,12 @@ func (c *Connection) parseOpenArgs(args ...interface{}) (*DbConfigCluster, error
9999
if typeName, err = across.Getter(fileOrDriverType); err == nil {
100100
switch typeName {
101101
case "driver":
102-
dbConf.Master.Driver = fileOrDriverType
103-
dbConf.Master.Dsn = dsnOrFile
102+
//dbConf.Master.Driver = fileOrDriverType
103+
//dbConf.Master.Dsn = dsnOrFile
104+
dbConf.Master = &DbConfigSingle{
105+
Driver:fileOrDriverType,
106+
Dsn:dsnOrFile,
107+
}
104108

105109
case "file":
106110
// 配置文件, 读取配置文件

examples/connect.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package main
2+
3+
import (
4+
"fmt"
5+
"github.com/gohouse/gorose"
6+
_ "github.com/mattn/go-sqlite3"
7+
)
8+
9+
func main() {
10+
connection, err := gorose.Open([]interface{}{"sqlite3","./db.sqlite"}...)
11+
if err != nil {
12+
panic(err)
13+
}
14+
15+
res,err := connection.Table("users").First()
16+
fmt.Println(res,err)
17+
}

0 commit comments

Comments
 (0)