|
|
|
|
@ -97,7 +97,9 @@ type DataSourceHandler struct { |
|
|
|
|
log log.Logger |
|
|
|
|
dsInfo DataSourceInfo |
|
|
|
|
rowLimit int64 |
|
|
|
|
session *xorm.Session |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
type QueryJson struct { |
|
|
|
|
RawSql string `json:"rawSql"` |
|
|
|
|
Fill bool `json:"fill"` |
|
|
|
|
@ -145,6 +147,7 @@ func NewQueryDataHandler(config DataPluginConfiguration, queryResultTransformer |
|
|
|
|
queryDataHandler.metricColumnTypes = config.MetricColumnTypes |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Create the xorm engine
|
|
|
|
|
engine, err := NewXormEngine(config.DriverName, config.ConnectionString) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
@ -155,6 +158,11 @@ func NewQueryDataHandler(config DataPluginConfiguration, queryResultTransformer |
|
|
|
|
engine.SetConnMaxLifetime(time.Duration(config.DSInfo.JsonData.ConnMaxLifetime) * time.Second) |
|
|
|
|
|
|
|
|
|
queryDataHandler.engine = engine |
|
|
|
|
|
|
|
|
|
// Create the xorm session
|
|
|
|
|
session := engine.NewSession() |
|
|
|
|
queryDataHandler.session = session |
|
|
|
|
|
|
|
|
|
return &queryDataHandler, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -265,9 +273,7 @@ func (e *DataSourceHandler) executeQuery(query backend.DataQuery, wg *sync.WaitG |
|
|
|
|
return |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
session := e.engine.NewSession() |
|
|
|
|
defer session.Close() |
|
|
|
|
db := session.DB() |
|
|
|
|
db := e.session.DB() |
|
|
|
|
|
|
|
|
|
rows, err := db.QueryContext(queryContext, interpolatedQuery) |
|
|
|
|
if err != nil { |
|
|
|
|
|