Commit 9c8733ac by Daniel Lee Committed by GitHub

Merge pull request #11093 from svenklemm/postgres-connection

postgres: use net/url to generate postgres connection url
parents 7ce63169 4904a051
...@@ -54,7 +54,8 @@ func generateConnectionString(datasource *models.DataSource) string { ...@@ -54,7 +54,8 @@ func generateConnectionString(datasource *models.DataSource) string {
} }
sslmode := datasource.JsonData.Get("sslmode").MustString("verify-full") sslmode := datasource.JsonData.Get("sslmode").MustString("verify-full")
return fmt.Sprintf("postgres://%s:%s@%s/%s?sslmode=%s", url.PathEscape(datasource.User), url.PathEscape(password), url.PathEscape(datasource.Url), url.PathEscape(datasource.Database), url.QueryEscape(sslmode)) u := &url.URL{Scheme: "postgres", User: url.UserPassword(datasource.User, password), Host: datasource.Url, Path: datasource.Database, RawQuery: "sslmode=" + sslmode}
return u.String()
} }
func (e *PostgresQueryEndpoint) Query(ctx context.Context, dsInfo *models.DataSource, tsdbQuery *tsdb.TsdbQuery) (*tsdb.Response, error) { func (e *PostgresQueryEndpoint) Query(ctx context.Context, dsInfo *models.DataSource, tsdbQuery *tsdb.TsdbQuery) (*tsdb.Response, error) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment