Skip to content

Commit 4915d76

Browse files
committedJun 26, 2016
db manager: show database name in postgis connection details (fixes #3489)
(cherry picked from commit ecf3b37)
1 parent ca86571 commit 4915d76

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed
 

‎python/plugins/db_manager/db_plugins/postgis/connector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ def __init__(self, uri):
125125

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

128-
c = self._execute(None, u"SELECT current_user")
129-
self.user = self._fetchone(c)
128+
c = self._execute(None, u"SELECT current_user,current_database()")
129+
self.user, self.dbname = self._fetchone(c)
130130
self._close_cursor(c)
131131

132132
self._checkSpatial()

‎python/plugins/db_manager/db_plugins/postgis/info_model.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,21 @@
2222

2323
from PyQt4.QtGui import QApplication
2424

25-
from ..info_model import TableInfo, VectorTableInfo, RasterTableInfo
25+
from ..info_model import TableInfo, VectorTableInfo, RasterTableInfo, DatabaseInfo
2626
from ..html_elems import HtmlSection, HtmlParagraph, HtmlTable, HtmlTableHeader, HtmlTableCol
2727

2828

29+
class PGDatabaseInfo(DatabaseInfo):
30+
31+
def connectionDetails(self):
32+
tbl = [
33+
(QApplication.translate("DBManagerPlugin", "Host:"), self.db.connector.host),
34+
(QApplication.translate("DBManagerPlugin", "User:"), self.db.connector.user),
35+
(QApplication.translate("DBManagerPlugin", "Database:"), self.db.connector.dbname)
36+
]
37+
return HtmlTable(tbl)
38+
39+
2940
class PGTableInfo(TableInfo):
3041

3142
def __init__(self, table):

‎python/plugins/db_manager/db_plugins/postgis/plugin.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,10 @@ def connectorsFactory(self, uri):
111111
def dataTablesFactory(self, row, db, schema=None):
112112
return PGTable(row, db, schema)
113113

114+
def info(self):
115+
from .info_model import PGDatabaseInfo
116+
return PGDatabaseInfo(self)
117+
114118
def vectorTablesFactory(self, row, db, schema=None):
115119
return PGVectorTable(row, db, schema)
116120

0 commit comments

Comments
 (0)
Please sign in to comment.