Skip to content
Permalink
Browse files

For GDAL sake extract a dbname from the connection

Works around GDAL limitation reported in:
https://trac.osgeo.org/gdal/ticket/6910

Ref #16625
Ref #16626
  • Loading branch information
strk committed Jun 2, 2017
1 parent 861cf9a commit 78c3423861c278e3e5633098d559c9579819f5c4
Showing with 9 additions and 2 deletions.
  1. +9 −2 python/plugins/db_manager/db_plugins/postgis/plugin.py
@@ -310,8 +310,6 @@ def info(self):
def gdalUri(self, uri=None):
if not uri:
uri = self.database().uri()
# NOTE: service-only URIs won't work with GDAL up to 2.2.x
# See: https://issues.qgis.org/issues/16626
service = (u'service=%s' % uri.service()) if uri.service() else ''
schema = (u'schema=%s' % self.schemaName()) if self.schemaName() else ''
dbname = (u'dbname=%s' % uri.database()) if uri.database() else ''
@@ -320,6 +318,15 @@ def gdalUri(self, uri=None):
passw = (u'password=%s' % uri.password()) if uri.password() else ''
port = (u'port=%s' % uri.port()) if uri.port() else ''

if not dbname:
# GDAL postgisraster driver *requires* ad dbname
# See: https://trac.osgeo.org/gdal/ticket/6910
# TODO: cache this ?
connector = self.database().connector
r = connector._execute(None, "SELECT current_database()")
dbname = (u'dbname=%s' % connector._fetchone(r)[0])
connector._close_cursor(r)

# Find first raster field
col = ''
for fld in self.fields():

0 comments on commit 78c3423

Please sign in to comment.
You can’t perform that action at this time.