|
@@ -89,7 +89,13 @@ func NewClient(config *csconfig.DatabaseCfg) (*Client, error) {
|
|
|
}
|
|
|
client = ent.NewClient(ent.Driver(drv), entOpt)
|
|
|
case "mysql":
|
|
|
- drv, err := getEntDriver("mysql", dialect.MySQL, fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?parseTime=True", config.User, config.Password, config.Host, config.Port, config.DbName), config)
|
|
|
+ connString := ""
|
|
|
+ if config.Host == "" && config.Port == 0 && config.DbPath != "" {
|
|
|
+ connString = fmt.Sprintf("%s:%s@unix(%s)/%s?parseTime=True", config.User, config.Password, config.DbPath, config.DbName)
|
|
|
+ } else {
|
|
|
+ connString = fmt.Sprintf("%s:%s@tcp(%s:%d)/%s?parseTime=True", config.User, config.Password, config.Host, config.Port, config.DbName)
|
|
|
+ }
|
|
|
+ drv, err := getEntDriver("mysql", dialect.MySQL, connString, config)
|
|
|
if err != nil {
|
|
|
return &Client{}, fmt.Errorf("failed opening connection to mysql: %v", err)
|
|
|
}
|