I am currently trying to write my first Python plugin for QGIS and I'm using the the
uri = QgsDataSourceURI()
uri.setConnection(host,port,db,username,password)
syntax to create a connection to an Oracle database. This can then be passed to a QgsVectorLayer(uri.uri(), name, "oracle") command and the layer is added.
The trouble is that before calling this code I am asking the end user for the username and password. The details given are stored to save asking them again.
If they give incorrect details then QGIS will automatically ask them to correct the details but this is outside the scope of my Plugin and so the stored credentials would be wrong.
I want to check the credentials are valid after asking for them but before I try to add the layer.
Is there a way to use my constructed URI in python so that the database will tell me if they are valid?
Something like QgsCredentials but just returning true/false depending on the response of the server.