Skip to content

Commit

Permalink
db manager: show database name in postgis connection details (fixes #…
Browse files Browse the repository at this point in the history
…3489)

(cherry picked from commit ecf3b37)
  • Loading branch information
jef-n committed Jun 26, 2016
1 parent ca86571 commit 4915d76
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
4 changes: 2 additions & 2 deletions python/plugins/db_manager/db_plugins/postgis/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,8 +125,8 @@ def __init__(self, uri):

self.connection.set_isolation_level(psycopg2.extensions.ISOLATION_LEVEL_AUTOCOMMIT)

c = self._execute(None, u"SELECT current_user")
self.user = self._fetchone(c)
c = self._execute(None, u"SELECT current_user,current_database()")
self.user, self.dbname = self._fetchone(c)
self._close_cursor(c)

self._checkSpatial()
Expand Down
13 changes: 12 additions & 1 deletion python/plugins/db_manager/db_plugins/postgis/info_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,21 @@

from PyQt4.QtGui import QApplication

from ..info_model import TableInfo, VectorTableInfo, RasterTableInfo
from ..info_model import TableInfo, VectorTableInfo, RasterTableInfo, DatabaseInfo
from ..html_elems import HtmlSection, HtmlParagraph, HtmlTable, HtmlTableHeader, HtmlTableCol


class PGDatabaseInfo(DatabaseInfo):

def connectionDetails(self):
tbl = [
(QApplication.translate("DBManagerPlugin", "Host:"), self.db.connector.host),
(QApplication.translate("DBManagerPlugin", "User:"), self.db.connector.user),
(QApplication.translate("DBManagerPlugin", "Database:"), self.db.connector.dbname)
]
return HtmlTable(tbl)


class PGTableInfo(TableInfo):

def __init__(self, table):
Expand Down
4 changes: 4 additions & 0 deletions python/plugins/db_manager/db_plugins/postgis/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,10 @@ def connectorsFactory(self, uri):
def dataTablesFactory(self, row, db, schema=None):
return PGTable(row, db, schema)

def info(self):
from .info_model import PGDatabaseInfo
return PGDatabaseInfo(self)

def vectorTablesFactory(self, row, db, schema=None):
return PGVectorTable(row, db, schema)

Expand Down

0 comments on commit 4915d76

Please sign in to comment.