Better error message when failed to open DB

hopefully gives some hints why the db manager tests sometimes fail
This commit is contained in:
Matthias Kuhn 2019-02-21 21:57:27 +01:00
parent 9f77b2dd23
commit 1f4747fe62
No known key found for this signature in database
GPG Key ID: 7A7F1A1C90C3E6A7

View File

@ -59,8 +59,10 @@ class GPKGDBConnector(DBConnector):
self.gdal_ds = gdal.OpenEx(self.dbname, gdal.OF_UPDATE)
if self.gdal_ds is None:
self.gdal_ds = gdal.OpenEx(self.dbname)
if self.gdal_ds is None or self.gdal_ds.GetDriver().ShortName != 'GPKG':
if self.gdal_ds is None:
raise ConnectionError(QApplication.translate("DBManagerPlugin", '"{0}" not found').format(self.dbname))
if self.gdal_ds.GetDriver().ShortName != 'GPKG':
raise ConnectionError(QApplication.translate("DBManagerPlugin", '"{dbname}" not recognized as GPKG ({shortname} reported instead.)').format(dbname=self.dbname, shortname=self.gdal_ds.GetDriver().ShortName))
self.has_raster = self.gdal_ds.RasterCount != 0 or self.gdal_ds.GetMetadata('SUBDATASETS') is not None
self.connection = None