Skip to content

Commit

Permalink
revert
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangsheng committed Dec 10, 2020
1 parent 2f80873 commit aa77fe7
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 39 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
38 changes: 0 additions & 38 deletions r.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

// 发版标记
Expand All @@ -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) {
Expand All @@ -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
Expand Down

0 comments on commit aa77fe7

Please sign in to comment.