I was trying to make connection to my PSQL
database but when I checked:
dbliste = QtSql.QSqlDatabase.drivers() print(dbliste),
i got this:
['QSQLITE', 'QODBC', 'QODBC3']
Why I don't have drivers for QPSQL
installed? Where can I download them?
from PyQt5 import QtWidgets, QtSql
def createConnection():
db = QtSql.QSqlDatabase.addDatabase("QPSQL")
db.setHostName('localhost')
db.setPort(5432)
db.setDatabaseName('DB_real')
db.setUserName('postgres')
db.setPassword('****')
if not db.open():
QtWidgets.QMessageBox.critical(None, "Cannot open database",
"Unable to establish a database connection.\n"
"Click Cancel to exit.", QtWidgets.QMessageBox.Cancel)
return False
dbliste = QtSql.QSqlDatabase.drivers()
print(dbliste)