You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
720 B

  1. // Copyright 2015 The Xorm Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. package xorm
  5. import (
  6. "errors"
  7. "strings"
  8. "github.com/go-xorm/core"
  9. )
  10. type odbcDriver struct {
  11. }
  12. func (p *odbcDriver) Parse(driverName, dataSourceName string) (*core.Uri, error) {
  13. kv := strings.Split(dataSourceName, ";")
  14. var dbName string
  15. for _, c := range kv {
  16. vv := strings.Split(strings.TrimSpace(c), "=")
  17. if len(vv) == 2 {
  18. switch strings.ToLower(vv[0]) {
  19. case "database":
  20. dbName = vv[1]
  21. }
  22. }
  23. }
  24. if dbName == "" {
  25. return nil, errors.New("no db name provided")
  26. }
  27. return &core.Uri{DbName: dbName, DbType: core.MSSQL}, nil
  28. }