Debugging PyQt5 QSql
Answered
Hi
I have challenge finding a bug when calling db.open(), I can't trace the code, anyone who have an idea how to debug QtPy4/5?
Running Win10 64 on Bootcamp Mac Pro , Python 3.6.1
The code for short is
from PyQt5.QtWidgets import QMessageBox
from PyQt5.QtSql import QSqlDatabase
from configparser import RawConfigParser
def createconnection():
parser = RawConfigParser()
parser.read('Qtabwindow.cfg')
result =QSqlDatabase.isDriverAvailable('QMYSQL')
print(result)
db = QSqlDatabase.addDatabase('QMYSQL')
db.setHostName(parser.get("DEFAULT", 'Hostname'))
db.setDatabaseName(parser.get('DEFAULT', 'DatabaseName'))
db.setUserName(parser.get('DEFAULT', 'UserName'))
db.setPassword(parser.get('DEFAULT', 'PassWord'))
if not db.open():
'''
QMessageBox.critical(None, 'Cannot open database \
Unable to establish a database connection.\
This example needs SQL support.Please read the Qt SQL',
QMessageBox.Cancel)
'''
return False
return True
Please sign in to leave a comment.
Hi Gert! Does "-1" mean that the problem is not relevant for you now?
Hi Anna! Yes, the problem is still very relevant and I can't figure out how to solve it. I have checked almost all sites like Stack overflow and also contacted Phil Thompson at Riverbank Computing, but no reply.