[PyQt] Pyqt5.9 MySQL driver not loaded

gj at hd-doc.com gj at hd-doc.com
Sun Jul 30 22:28:32 BST 2017


Why is the MySQL driver not loaded when it’s available in C:\Python36\Lib\site-packages\PyQt5\Qt\plugins\sqldrivers\qsqlmysql.dll and print(db.isDriverAvailable('QMYSQL'))
Returns True.
The setup is win10, Python 3.6.2 and installing the latest wheel Pyqt5.9.1 and SIP 4.19.3 by Pip 9.01.  Hope someone can help me solving this time consuming problem finding and no solutions.
The Code:
# coding=utf-8
from PyQt5.QtWidgets import QMessageBox
from PyQt5 import QtSql
def createconnection():
db = QtSql.QSqlDatabase.addDatabase('MYSQL')
print(db.isDriverAvailable('QMYSQL'))
db.setHostName("192.168.1.225")
db.setPort(3306)
db.setDatabaseName("Database_dispo_4")
db.setUserName("T3")
db.setPassword("xxxx")
print(db.open())
print(db.lastError().text())
print(db.drivers()


Consol output
C:\Python36\python.exe "C:\Program Files\JetBrains\PyCharm 2017.2\helpers\pydev\pydevd.py" --multiproc --qt-support=auto --client 127.0.0.1 --port 54371 --file C:/Users/Doc/Documents/Pyqt_SQL/src/Qtabwindow.py
pydev debugger: process 4020 is connecting

Connected to pydev debugger (build 172.3317.103)
True
False
Driver not loaded Driver not loaded
['QSQLITE', 'QMYSQL', 'QMYSQL3', 'QODBC', 'QODBC3', 'QPSQL', 'QPSQL7']

Kind regards
Gert Jorgensen

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.riverbankcomputing.com/pipermail/pyqt/attachments/20170730/9eb4d56d/attachment.html>


More information about the PyQt mailing list