I am designing a GUI for a QGIS plugin I am developing, which is intended to plot information from a MySQL database. In the GUI, I would like to have a combo box of all the database connections saved in QGIS.
These can be viewed by printing allKeys()
for QSettings()
in PyQt4.QtCore
. When this is done, the keys I am interested in are:
...
MySQL/connections/adsb/database
MySQL/connections/adsb/host
MySQL/connections/adsb/password
MySQL/connections/adsb/port
MySQL/connections/adsb/save
MySQL/connections/adsb/username
MySQL/connections/database
MySQL/connections/host
MySQL/connections/password
MySQL/connections/port
MySQL/connections/save
MySQL/connections/selected
MySQL/connections/strath_adsb/database
MySQL/connections/strath_adsb/host
MySQL/connections/strath_adsb/password
MySQL/connections/strath_adsb/port
MySQL/connections/strath_adsb/save
MySQL/connections/strath_adsb/username
...
Where 'adsb' and 'strath_adsb' are databases. How would it be possible to read the names of all connected databases and store them in an array, so that they could then be displayed as options in the combo box?