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.
26 lines
491 B
26 lines
491 B
package dorm
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
_ "gitee.com/chunanyong/dm"
|
|
"gitee.com/chunanyong/zorm"
|
|
)
|
|
|
|
func NewZormDmClient(config *ConfigZormClient) (*ZormClient, error) {
|
|
|
|
var err error
|
|
c := &ZormClient{config: config}
|
|
|
|
c.Db, err = zorm.NewDBDao(&zorm.DataSourceConfig{
|
|
DSN: c.config.Dns,
|
|
DriverName: "dm", // 数据库驱动名称
|
|
DBType: "dm", // 数据库类型
|
|
})
|
|
if err != nil {
|
|
return nil, errors.New(fmt.Sprintf("连接失败:%v", err))
|
|
}
|
|
|
|
return c, nil
|
|
}
|