Merge pull request #13705 from Yukinoshita-Yukino/master
Add socket support for mysql data source
This commit is contained in:
@@ -5,6 +5,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"reflect"
|
"reflect"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"strings"
|
||||||
|
|
||||||
"github.com/go-sql-driver/mysql"
|
"github.com/go-sql-driver/mysql"
|
||||||
"github.com/go-xorm/core"
|
"github.com/go-xorm/core"
|
||||||
@@ -20,10 +21,14 @@ func init() {
|
|||||||
func newMysqlQueryEndpoint(datasource *models.DataSource) (tsdb.TsdbQueryEndpoint, error) {
|
func newMysqlQueryEndpoint(datasource *models.DataSource) (tsdb.TsdbQueryEndpoint, error) {
|
||||||
logger := log.New("tsdb.mysql")
|
logger := log.New("tsdb.mysql")
|
||||||
|
|
||||||
|
protocol := "tcp"
|
||||||
|
if strings.HasPrefix(datasource.Url, "/") {
|
||||||
|
protocol = "unix"
|
||||||
|
}
|
||||||
cnnstr := fmt.Sprintf("%s:%s@%s(%s)/%s?collation=utf8mb4_unicode_ci&parseTime=true&loc=UTC&allowNativePasswords=true",
|
cnnstr := fmt.Sprintf("%s:%s@%s(%s)/%s?collation=utf8mb4_unicode_ci&parseTime=true&loc=UTC&allowNativePasswords=true",
|
||||||
datasource.User,
|
datasource.User,
|
||||||
datasource.Password,
|
datasource.Password,
|
||||||
"tcp",
|
protocol,
|
||||||
datasource.Url,
|
datasource.Url,
|
||||||
datasource.Database,
|
datasource.Database,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user