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.
22 lines
376 B
22 lines
376 B
package dorm
|
|
|
|
import (
|
|
"errors"
|
|
"fmt"
|
|
_ "github.com/go-sql-driver/mysql"
|
|
"xorm.io/xorm"
|
|
)
|
|
|
|
func NewXormMysqlClient(config *XormClientConfigXorm) (*XormClient, error) {
|
|
|
|
var err error
|
|
c := &XormClient{config: config}
|
|
|
|
c.db, err = xorm.NewEngine("mysql", c.config.Dns)
|
|
if err != nil {
|
|
return nil, errors.New(fmt.Sprintf("连接失败:%v", err))
|
|
}
|
|
|
|
return c, nil
|
|
}
|