I created a plugin in QGIS.
Then I created a Qt GUI for my plugin and finally created a PostgreSQL database.
Now I need to make a connection between Qt-GUI and PostgreSQL database.
I wrote this:
from PyQt4.QtSql import *
db = QSqlDatabase.addDatabase("QPSQL")
db.setHostName("localhost")
db.setDatabaseName("siti")
db.setUserName("postgres")
db.setPassword("bina")
bool ok = db.open()
but it doesn't work.
Can you help me?