Feature request #11604
DB Manager needs option to create a database connection
Status: | Closed | ||
---|---|---|---|
Priority: | Low | ||
Assignee: | - | ||
Category: | DB Manager | ||
Pull Request or Patch supplied: | No | Resolution: | duplicate |
Easy fix?: | No | Copied to github as #: | 19861 |
Description
The DB Manager window currently has no option to create a new database connection. To create a connection to PostgreSQL I have to use the SPIT tool, after which the newly created connection can be selected in DB Manager.
History
#1 Updated by Paolo Cavallini about 10 years ago
No need for SPIT, you can add a connection from the Browser
#2 Updated by Giuseppe Sucameli about 9 years ago
- Priority changed from Normal to Low
In this moment DBManager allows to add new Spatialite connections only.
Anyway you can add new PostgreSQL connections using "Add Postgis layer" from QGIS.
#3 Updated by Larry Shaffer almost 9 years ago
- File postgres-conns.png added
Adding a Postgres connection manager (for convenience) could be done in two ways:
- Make a manager from scratch in Python
- Use the Postgres provider's
selectWidget()
and strip out the 'Add Layer' bits
- Edit the
QgsVectorDataProvider
external plugin interface to provide a newconnectionWidget()
for managing just connections
The following hack-ish code works to slim the provider's current select widget down to just a connection manager GUI:
from PyQt4.QtGui import * from PyQt4.QtCore import * dprovs = [d for d in QgsDataItemProviderRegistry.instance().providers() if 'postgres' in d.name()] if dprovs: dpitem = dprovs[0].createDataItem('', None) dpitemw = dpitem.paramWidget() dpiteml = dpitemw.layout() grpbxitem = None for i in range(0, dpiteml.count()): w = dpiteml.itemAt(i).widget() if w and w.objectName() == 'connectionsGroupBox': grpbxitem = dpiteml.takeAt(i) break if grpbxitem: btn = grpbxitem.widget().findChild(QPushButton, 'btnConnect') if btn: btn.setVisible(False) dlg = QDialog() dlg.setWindowTitle('Postgres Connections') lay = QVBoxLayout() lay.addItem(grpbxitem) btnbx = QDialogButtonBox(QDialogButtonBox.Ok | QDialogButtonBox.Cancel) lay.addWidget(btnbx) btnbx.accepted.connect(dlg.accept) btnbx.rejected.connect(dlg.reject) dlg.setLayout(lay) if dlg.exec_(): # refresh the Postgres tree item print 'accepted'
See attached screenshot. This could be implemented as an action in the contextual menu for the Postgres parent tree item and as a toolbar action.
#4 Updated by Paolo Cavallini about 8 years ago
- Resolution set to duplicate
- Status changed from Open to Closed
Duplicate of #4795