diff --git a/layer.go b/layer.go index 7bf32d6..e45c0ef 100644 --- a/layer.go +++ b/layer.go @@ -56,7 +56,7 @@ func (manager *ManagerConfig) PublishGeoserverLayer(layer *GdalLayer) (ok bool, //LayerToPostgis add Layer to Postgis func (layer *GdalLayer) LayerToPostgis(targetSource *gdal.DataSource, manager *ManagerConfig, overwrite bool) (newLayer *GdalLayer, err error) { connStr := manager.Datastore.PostgresConnectionString() - dbErr := DBIsAlive(connStr) + dbErr := DBIsAlive("postgres", connStr) if dbErr != nil { err = dbErr return diff --git a/utils.go b/utils.go index e9b9f81..948bc28 100644 --- a/utils.go +++ b/utils.go @@ -73,8 +73,8 @@ func GetGISFiles(root string) ([]string, error) { } //DBIsAlive check if database alive -func DBIsAlive(connectionStr string) (err error) { - db, dbErr := sql.Open("postgres", connectionStr) +func DBIsAlive(dbType string, connectionStr string) (err error) { + db, dbErr := sql.Open(dbType, connectionStr) if dbErr != nil { err = dbErr return diff --git a/utils_test.go b/utils_test.go index 7900668..60bb682 100644 --- a/utils_test.go +++ b/utils_test.go @@ -27,9 +27,9 @@ func TestGetGISFiles(t *testing.T) { func TestDBIsAlive(t *testing.T) { manager, _ := FromConfig("./testdata/test_config.yml") connStr := manager.Datastore.PostgresConnectionString() - dbErr := DBIsAlive(connStr) + dbErr := DBIsAlive("postgres", connStr) assert.Nil(t, dbErr) - connStr = "xxxxx" - err := DBIsAlive(connStr) + connStr = "mysql://" + err := DBIsAlive("mysql", connStr) assert.NotNil(t, err) }