My system: Windows 10 Pro 16299, Qt, PyQt 5.11.2, Python 3.6, PostgreSql 10
I tried to use QTableView/QSqlTableModel for in my gui to work with postgresql data. However, I am not able to open the database. I get the error message “Driver not loaded Driver not loaded”.
A new installation of Qt, PostgreSql and PyQt has not solved the problem. I tried also “Dependency Walker” to look for missing dlls, but was not able use the given information.
Do you have an idea how to fix this problem?
As an alternative: Is it possible to use QTableView/QSqlTableModel with psycopg2 (instead of QSqlDatabase)?
Thank you very much in advance!
from PyQt5.QtSql import QSqlDatabase, QSqlQuery, QSqlTableModel
from PyQt5.QtWidgets import QTableView, QApplication
import sys
if __name__ == '__main__':
app = QApplication(sys.argv)
db = QSqlDatabase.addDatabase("QPSQL")
db.setHostName("localhost")
db.setPort(5432)
db.setDatabaseName("Test")
db.setUserName("postgres")
db.setPassword("xxxxx")
if (db.open() == False):
QMessageBox.critical(None, "Error", db.lastError().text())
else:
Print("Connected")
Dependency Walker Screenshot