thecodemonkey86 / qt_mysql_driver

Typical symptom: QMYSQL driver not loaded. Solution: get pre-built Qt SQL driver plug-in required to establish a connection to MySQL / MariaDB using Qt. Download qsqlmysql.dll binaries built from official Qt source code
Other
417 stars 58 forks source link

Cannot load the driver from PyQt5 #9

Closed moham96 closed 3 years ago

moham96 commented 3 years ago

Hi, I'm unable to load the driver using a pyqt5 app, for my environment pyqt5 is installed through pip and the version is 5.15.2 so I downloaded the following version qsqlmysql.dll_Qt_SQL_driver_5.15.2_MSVC2019_64-bit.zip since I know that PyQt5 is compiled with msvc and not mingw i placed the files in this directory: C:\Users\mohammad\AppData\Local\Programs\Python\Python38\Lib\site-packages\PyQt5\Qt\plugins\sqldrivers along with the libssl,libmysql and libcrypto dlls for simplicity. I then used https://github.com/lucasg/Dependencies/ to check the qmysql.dll for a missing dependency and there doesn't seem anything missing.

than I used the following script to test:

from PyQt5 import QtCore
from PyQt5 import QtWidgets
from PyQt5 import QtSql
import sys

app = QtWidgets.QApplication(sys.argv)

database = QtSql.QSqlDatabase()

database.addDatabase("QMYSQL")

print("QT version is: {}".format(QtCore.QT_VERSION_STR))
print("Library path is {}".format(QtCore.QCoreApplication.libraryPaths()))

And I got the following output:

PS C:\Users\mohammad\Desktop> python .\qsqldatabase.py
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platforms" ...
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platforms/qminimal.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platforms/qminimal.dll, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "minimal"
        ]
    },
    "archreq": 0,
    "className": "QMinimalIntegrationPlugin",
    "debug": false,
    "version": 331520
}

Got keys from plugin meta data ("minimal")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platforms/qoffscreen.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platforms/qoffscreen.dll, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "offscreen"
        ]
    },
    "archreq": 0,
    "className": "QOffscreenIntegrationPlugin",
    "debug": false,
    "version": 331520
}

Got keys from plugin meta data ("offscreen")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platforms/qwebgl.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platforms/qwebgl.dll, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "webgl"
        ]
    },
    "archreq": 0,
    "className": "QWebGLIntegrationPlugin",
    "debug": false,
    "version": 331520
}

Got keys from plugin meta data ("webgl")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platforms/qwindows.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platforms/qwindows.dll, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformIntegrationFactoryInterface.5.3",
    "MetaData": {
        "Keys": [
            "windows"
        ]
    },
    "archreq": 0,
    "className": "QWindowsIntegrationPlugin",
    "debug": false,
    "version": 331520
}

Got keys from plugin meta data ("windows")
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/platforms" ...
loaded library "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platforms/qwindows.dll"
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platformthemes" ...
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platformthemes/qxdgdesktopportal.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platformthemes/qxdgdesktopportal.dll, metadata=
{
    "IID": "org.qt-project.Qt.QPA.QPlatformThemeFactoryInterface.5.1",
    "MetaData": {
        "Keys": [
            "xdgdesktopportal",
            "flatpak",
            "snap"
        ]
    },
    "archreq": 0,
    "className": "QXdgDesktopPortalThemePlugin",
    "debug": false,
    "version": 331520
}

Got keys from plugin meta data ("xdgdesktopportal", "flatpak", "snap")
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/platformthemes" ...
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/styles" ...
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/styles/qwindowsvistastyle.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/styles/qwindowsvistastyle.dll, metadata=
{
    "IID": "org.qt-project.Qt.QStyleFactoryInterface",
    "MetaData": {
        "Keys": [
            "windowsvista"
        ]
    },
    "archreq": 0,
    "className": "QWindowsVistaStylePlugin",
    "debug": false,
    "version": 331520
}

Got keys from plugin meta data ("windowsvista")
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/styles" ...
loaded library "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/styles/qwindowsvistastyle.dll"
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers" ...
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/libcrypto-1_1-x64.dll"
"Failed to extract plugin meta data from 'C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/libcrypto-1_1-x64.dll'"
         not a plugin
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/libmysql.dll"
"Failed to extract plugin meta data from 'C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/libmysql.dll'"
         not a plugin
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/libssl-1_1-x64.dll"
"Failed to extract plugin meta data from 'C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/libssl-1_1-x64.dll'"
         not a plugin
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlite.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlite.dll, metadata=
{
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
        "Keys": [
            "QSQLITE"
        ]
    },
    "archreq": 0,
    "className": "QSQLiteDriverPlugin",
    "debug": false,
    "version": 331520
}

Got keys from plugin meta data ("QSQLITE")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlmysql.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlmysql.dll, metadata=
{
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
        "Keys": [
            "QMYSQL3",
            "QMYSQL",
            "QMARIADB"
        ]
    },
    "archreq": 0,
    "className": "QMYSQLDriverPlugin",
    "debug": false,
    "version": 331520
}

Got keys from plugin meta data ("QMYSQL3", "QMYSQL", "QMARIADB")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlmysqld.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlmysqld.dll, metadata=
{
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
        "Keys": [
            "QMYSQL3",
            "QMYSQL",
            "QMARIADB"
        ]
    },
    "archreq": 1,
    "className": "QMYSQLDriverPlugin",
    "debug": true,
    "version": 331520
}

"The plugin 'C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlmysqld.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)"
         not a plugin
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlodbc.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlodbc.dll, metadata=
{
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
        "Keys": [
            "QODBC3",
            "QODBC"
        ]
    },
    "archreq": 0,
    "className": "QODBCDriverPlugin",
    "debug": false,
    "version": 331520
}

Got keys from plugin meta data ("QODBC3", "QODBC")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlpsql.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlpsql.dll, metadata=
{
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
        "Keys": [
            "QPSQL7",
            "QPSQL"
        ]
    },
    "archreq": 0,
    "className": "QPSQLDriverPlugin",
    "debug": false,
    "version": 331520
}

Got keys from plugin meta data ("QPSQL7", "QPSQL")
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/sqldrivers" ...
Cannot load library C:\Users\mohammad\AppData\Local\Programs\Python\Python38\lib\site-packages\PyQt5\Qt\plugins\sqldrivers\qsqlmysql.dll: The specified module could not be found.
QLibraryPrivate::loadPlugin failed on "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlmysql.dll" : "Cannot load library C:\\Users\\mohammad\\AppData\\Local\\Programs\\Python\\Python38\\lib\\site-packages\\PyQt5\\Qt\\plugins\\sqldrivers\\qsqlmysql.dll: The specified module could not be found."
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7
QT version is: 5.15.2
Library path is ['C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins', 'C:/Users/mohammad/AppData/Local/Programs/Python/Python38']
QLibraryPrivate::unload succeeded on "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/styles/qwindowsvistastyle.dll"
QLibraryPrivate::unload succeeded on "C:/Users/mohammad/AppData/Local/Programs/Python/Python38/lib/site-packages/PyQt5/Qt/plugins/platforms/qwindows.dll"

What did I do wrong?

thecodemonkey86 commented 3 years ago

hi, did you try putting libmysql and the OpenSSL libs into a folder which is registered in the PATH variable?

moham96 commented 3 years ago

hi, did you try putting libmysql and the OpenSSL libs into a folder which is registered in the PATH variable?

I also placed them in this system32 and it didn't help

moham96 commented 3 years ago

I don't know if the compiler version difference can cause a problem(to be honest I don't use windows that often so I don't know how dlls work). this is the qsqlite.dll info (this dll is shipped with pyqt and works as expected) image

this the qmysql.dll info that I used: image

You can see that the compiler version is the same (v14) but the year is different, also the qsqlite.dll is signed with an x509 certificate while the qmysql.dll is not

thecodemonkey86 commented 3 years ago

I don't know if the compiler version difference can cause a problem(to be honest I don't use windows that often so I don't know how dlls work).

Probably not, because it works for me with PyQt5 "out of the box". I'm somewhat out of ideas. Does it work if you use C++ instead of Python?

moham96 commented 3 years ago

@thecodemonkey86 same problem with c++

Cannot load library C:\Qt\Qt5.14.2\5.14.2\msvc2017_64\plugins\sqldrivers\qsqlmysql.dll: The specified module could not be found.
QLibraryPrivate::loadPlugin failed on "C:/Qt/Qt5.14.2/5.14.2/msvc2017_64/plugins/sqldrivers/qsqlmysql.dll" : "Cannot load library C:\\Qt\\Qt5.14.2\\5.14.2\\msvc2017_64\\plugins\\sqldrivers\\qsqlmysql.dll: The specified module could not be found."

I wrote a program and finished it and it's working fine on Linux and now I have to deliver the program in windows and this problem has stopped me for 2 weeks, damn I thought PyQt is cross-platform and easy to port

moham96 commented 3 years ago

@thecodemonkey86 can you run the following code on your working machine and give the output so I can compare versions with my machine ?

from PyQt5.QtCore import QT_VERSION_STR
from PyQt5.Qt import PYQT_VERSION_STR
from PyQt5 import QtSql

from sip import SIP_VERSION_STR

import sys
import platform

print("Platform version:", platform.platform())
print("sys version:", sys.getwindowsversion())
print("Python version:", sys.version)
print("Qt version:", QT_VERSION_STR)
print("SIP version:", SIP_VERSION_STR)
print("PyQt version:", PYQT_VERSION_STR)

QtSql.QSqlDatabase().drivers()

be sure to set QT_DEBUG_PLUGINS=1 so the dlls metadata is returned

thecodemonkey86 commented 3 years ago

sure, the output on my machine is

Platform version: Windows-10-10.0.18362-SP0
sys version: sys.getwindowsversion(major=10, minor=0, build=18363, platform=2, service_pack='')
Python version: 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)]
Qt version: 5.15.2
SIP version: 5.4.0
PyQt version: 5.15.3
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Bernhard/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers" ...
QFactoryLoader::QFactoryLoader() looking at "C:/Users/Bernhard/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlite.dll"
Found metadata in lib C:/Users/Bernhard/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlite.dll, metadata=
{
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
        "Keys": [
            "QSQLITE"
        ]
    },
    "archreq": 0,
    "className": "QSQLiteDriverPlugin",
    "debug": false,
    "version": 331520
}

Got keys from plugin meta data ("QSQLITE")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/Bernhard/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlmysql.dll"
Found metadata in lib C:/Users/Bernhard/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlmysql.dll, metadata=
{
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
        "Keys": [
            "QMYSQL3",
            "QMYSQL",
            "QMARIADB"
        ]
    },
    "archreq": 0,
    "className": "QMYSQLDriverPlugin",
    "debug": false,
    "version": 331520
}

Got keys from plugin meta data ("QMYSQL3", "QMYSQL", "QMARIADB")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/Bernhard/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlodbc.dll"
Found metadata in lib C:/Users/Bernhard/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlodbc.dll, metadata=
{
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
        "Keys": [
            "QODBC3",
            "QODBC"
        ]
    },
    "archreq": 0,
    "className": "QODBCDriverPlugin",
    "debug": false,
    "version": 331520
}

Got keys from plugin meta data ("QODBC3", "QODBC")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/Bernhard/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlpsql.dll"
Found metadata in lib C:/Users/Bernhard/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlpsql.dll, metadata=
{
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
        "Keys": [
            "QPSQL7",
            "QPSQL"
        ]
    },
    "archreq": 0,
    "className": "QPSQLDriverPlugin",
    "debug": false,
    "version": 331520
}

Got keys from plugin meta data ("QPSQL7", "QPSQL")
moham96 commented 3 years ago

@thecodemonkey86 similar to my setup

Platform version: Windows-10-10.0.19041-SP0
sys version: sys.getwindowsversion(major=10, minor=0, build=19042, platform=2, service_pack='')
Python version: 3.9.0 (tags/v3.9.0:9cf6752, Oct  5 2020, 15:34:40) [MSC v.1927 64 bit (AMD64)]
Qt version: 5.15.2
SIP version: 5.4.0
PyQt version: 5.15.3
QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/mohammad/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers" ...
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlite.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlite.dll, metadata=
{
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
        "Keys": [
            "QSQLITE"
        ]
    },
    "archreq": 0,
    "className": "QSQLiteDriverPlugin",
    "debug": false,
    "version": 331520
}

Got keys from plugin meta data ("QSQLITE")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlmysql.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlmysql.dll, metadata=
{
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
        "Keys": [
            "QMYSQL3",
            "QMYSQL",
            "QMARIADB"
        ]
    },
    "archreq": 0,
    "className": "QMYSQLDriverPlugin",
    "debug": false,
    "version": 331520
}

Got keys from plugin meta data ("QMYSQL3", "QMYSQL", "QMARIADB")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlodbc.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlodbc.dll, metadata=
{
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
        "Keys": [
            "QODBC3",
            "QODBC"
        ]
    },
    "archreq": 0,
    "className": "QODBCDriverPlugin",
    "debug": false,
    "version": 331520
}

Got keys from plugin meta data ("QODBC3", "QODBC")
QFactoryLoader::QFactoryLoader() looking at "C:/Users/mohammad/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlpsql.dll"
Found metadata in lib C:/Users/mohammad/AppData/Local/Programs/Python/Python39/lib/site-packages/PyQt5/Qt/plugins/sqldrivers/qsqlpsql.dll, metadata=
{
    "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
    "MetaData": {
        "Keys": [
            "QPSQL7",
            "QPSQL"
        ]
    },
    "archreq": 0,
    "className": "QPSQLDriverPlugin",
    "debug": false,
    "version": 331520
}

Got keys from plugin meta data ("QPSQL7", "QPSQL")

I used the dlls from this zip (qsqlmysql.dll_Qt_SQL_driver_5.15.2_MSVC2019_64-bit.zip)

and the driver is not loaded as in the first message :(

moham96 commented 3 years ago

Ok after over a month of search and experiment the solution was very stupid, which is to put the libmysql.dll and qsqlmysql.dll in the same folder as the .py file we are launching and also put the them in the correct folder for pyqt, for example on my machine the Pyqt directory is this: C:\Users\USER\AppData\Local\Programs\Python\Python39\Lib\site-packages\PyQt5\Qt\plugins\sqldrivers substitute USER with your user.

The strange thing is that it seems that the dll is being loaded from the pyqt plugins directory as expected but for some reason it requires the files to be in the same app directory as well.

thecodemonkey86 commented 3 years ago

glad to hear you found a solution