-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
zhangsheng
committed
Dec 10, 2020
1 parent
2f80873
commit aa77fe7
Showing
2 changed files
with
0 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,4 @@ go 1.13 | |
require ( | ||
github.com/golang/snappy v0.0.1 | ||
golang.org/x/text v0.3.2 | ||
xorm.io/xorm v1.0.5 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,14 +8,8 @@ import ( | |
"context" | ||
"database/sql" | ||
"database/sql/driver" | ||
"errors" | ||
"fmt" | ||
"github.com/ilooky/dm/i18n" | ||
"regexp" | ||
"sync" | ||
"xorm.io/xorm" | ||
"xorm.io/xorm/dialects" | ||
"xorm.io/xorm/schemas" | ||
) | ||
|
||
// 发版标记 | ||
|
@@ -27,18 +21,6 @@ var globalDmDriver = newDmDriver() | |
|
||
func init() { | ||
sql.Register("dm", globalDmDriver) | ||
dialects.RegisterDriver("dm", globalDmDriver) | ||
} | ||
|
||
//dm://user:password@host:port?logLevel=all | ||
//%s/%s@%s:%s/ORCL | ||
func odbc() *xorm.Engine { | ||
engine, err := xorm.NewEngine("dm", "dm://SYSDBA:[email protected]:5236/oci8?logLevel=all") | ||
if err != nil { | ||
fmt.Println("new engine got error:", err) | ||
return nil | ||
} | ||
return engine | ||
} | ||
|
||
func driverInit(svcConfPath string) { | ||
|
@@ -63,26 +45,6 @@ type DmDriver struct { | |
readPropMutex sync.Mutex | ||
} | ||
|
||
func (d *DmDriver) Parse(driverName, dataSourceName string) (*dialects.URI, error) { | ||
db := &dialects.URI{DBType: schemas.ORACLE} | ||
dsnPattern := regexp.MustCompile( | ||
`^(?P<user>.*)\/(?P<password>.*)@` + // user:password@ | ||
`(?P<net>.*)` + // ip:port | ||
`\/(?P<dbname>.*)`) // dbname | ||
matches := dsnPattern.FindStringSubmatch(dataSourceName) | ||
names := dsnPattern.SubexpNames() | ||
for i, match := range matches { | ||
switch names[i] { | ||
case "dbname": | ||
db.DBName = match | ||
} | ||
} | ||
if db.DBName == "" && len(matches) != 0 { | ||
return nil, errors.New("dbname is empty") | ||
} | ||
return db, nil | ||
} | ||
|
||
func newDmDriver() *DmDriver { | ||
d := new(DmDriver) | ||
d.idGenerator = dmDriverIDGenerator | ||
|