mirror of
https://github.com/go-gitea/gitea
synced 2024-11-14 14:14:25 +00:00
35 lines
720 B
Go
35 lines
720 B
Go
|
// Copyright 2015 The Xorm Authors. All rights reserved.
|
||
|
// Use of this source code is governed by a BSD-style
|
||
|
// license that can be found in the LICENSE file.
|
||
|
|
||
|
package xorm
|
||
|
|
||
|
import (
|
||
|
"errors"
|
||
|
"strings"
|
||
|
|
||
|
"github.com/go-xorm/core"
|
||
|
)
|
||
|
|
||
|
type odbcDriver struct {
|
||
|
}
|
||
|
|
||
|
func (p *odbcDriver) Parse(driverName, dataSourceName string) (*core.Uri, error) {
|
||
|
kv := strings.Split(dataSourceName, ";")
|
||
|
var dbName string
|
||
|
|
||
|
for _, c := range kv {
|
||
|
vv := strings.Split(strings.TrimSpace(c), "=")
|
||
|
if len(vv) == 2 {
|
||
|
switch strings.ToLower(vv[0]) {
|
||
|
case "database":
|
||
|
dbName = vv[1]
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
if dbName == "" {
|
||
|
return nil, errors.New("no db name provided")
|
||
|
}
|
||
|
return &core.Uri{DbName: dbName, DbType: core.MSSQL}, nil
|
||
|
}
|