|
|
|
|
@ -5,6 +5,7 @@ import ( |
|
|
|
|
"fmt" |
|
|
|
|
"reflect" |
|
|
|
|
"strconv" |
|
|
|
|
"strings" |
|
|
|
|
|
|
|
|
|
"github.com/go-sql-driver/mysql" |
|
|
|
|
"github.com/go-xorm/core" |
|
|
|
|
@ -20,10 +21,16 @@ func init() { |
|
|
|
|
func newMysqlQueryEndpoint(datasource *models.DataSource) (tsdb.TsdbQueryEndpoint, error) { |
|
|
|
|
logger := log.New("tsdb.mysql") |
|
|
|
|
|
|
|
|
|
var protocol string |
|
|
|
|
if strings.HasPrefix(datasource.Url, "/") { |
|
|
|
|
protocol = "unix" |
|
|
|
|
} else { |
|
|
|
|
protocol = "tcp" |
|
|
|
|
} |
|
|
|
|
cnnstr := fmt.Sprintf("%s:%s@%s(%s)/%s?collation=utf8mb4_unicode_ci&parseTime=true&loc=UTC&allowNativePasswords=true", |
|
|
|
|
datasource.User, |
|
|
|
|
datasource.Password, |
|
|
|
|
"tcp", |
|
|
|
|
protocol, |
|
|
|
|
datasource.Url, |
|
|
|
|
datasource.Database, |
|
|
|
|
) |
|
|
|
|
|