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

QMySqlDrivers not Working #33

Closed The-VoyZ closed 1 year ago

The-VoyZ commented 1 year ago

I dont know if im just Stupid or what. But i dont seem to get it to Work at all. Im Trying to get the MySqlDrivers to Work but even after 8 Hours Compiling and Trouble shooting it wont work for me.

Information im not using QTDesign Studio. Im just using the Designer and PyQT6 with QT 6.5.1 (i also tryed downloading your Precompiled drivers) Even after trying some of the Suggestions from your Solved Issues. Copying them into the PyQt6 Python folder and also into the folder where the main.py is. Im getting this error:

QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL

Im totaly lost right now.

thecodemonkey86 commented 1 year ago

Hi, try the following:

The-VoyZ commented 1 year ago

Hi thanks for the fast answer. I tryed the steps you just posted :) But unfortunetly id doesnt work.

I got this debug output: (only the last few lines where the code got the error)

qt.core.plugin.factoryloader: Got keys from plugin meta data QList("QPSQL") qt.core.plugin.factoryloader: checking directory path "C:/Users/USER/AppData/Local/Programs/Python/Python311/sqldrivers" ... qt.core.library: "C:/Users/USER/AppData/Local/Programs/Python/Python311/Lib/site-packages/PyQt6/Qt6/plugins/sqldrivers/qsqlmysql.dll" cannot load: Cannot load library C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\PyQt6\Qt6\plugins\sqldrivers\qsqlmysql.dll: The specified module could not be found. qt.core.plugin.loader: QLibraryPrivate::loadPlugin failed on "C:/Users/USER/AppData/Local/Programs/Python/Python311/Lib/site-packages/PyQt6/Qt6/plugins/sqldrivers/qsqlmysql.dll" : "Cannot load library C:\Users\USER\AppData\Local\Programs\Python\Python311\Lib\site-packages\PyQt6\Qt6\plugins\sqldrivers\qsqlmysql.dll: The specified module could not be found." QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL Cannot establish a database connection, error: Driver not loaded Driver not loaded qt.core.plugin.factoryloader: checking directory path "C:/Users/USER/AppData/Local/Programs/Python/Python311/Lib/site-packages/PyQt6/Qt6/plugins/accessible" ... qt.core.plugin.factoryloader: checking directory path "C:/Users/USER/AppData/Local/Programs/Python/Python311/accessible" ... qt.core.plugin.factoryloader: checking directory path "C:/Users/USER/AppData/Local/Programs/Python/Python311/Lib/site-packages/PyQt6/Qt6/plugins/accessiblebridge" ... qt.core.plugin.factoryloader: checking directory path "C:/Users/USER/AppData/Local/Programs/Python/Python311/accessiblebridge" ...

Im running the code in vscode 2023. Using Python 3.11 I copied the qsqlmysql.dll in the corect path. And added the other files to a directory and set the path in the envirment variables : C:\MySqlDriver

i dont know if im understanding something wrong. Might it be possible to do this conversation in german ? Thanks in Advance !

The-VoyZ commented 1 year ago

I Double Checked the qsqlmysql.dll is in the correct folder and also the other 3 files are in the correct folder.

I tested it on a completly fresh Windows install. Just with PyQt6 installed and Packages needed for the code to run. Did all the steps again and i unfortunetly got the same result. I think im doing something wrong.

thecodemonkey86 commented 1 year ago

Might it be possible to do this conversation in german ?

Klar. Für mich sieht das so aus, als würde die qsqlmysql.dll immer noch nicht die libmysql.dll finden. Wie wurde der Pfad zur libmysql.dll in die PATH-Variable eingetragen? Falls über die Systemsteuerung, könnte es sein, dass man Windows neu starten muss, damit das überall greift. Ansonsten könnte evtl. noch Dependency Walker oder dessen modernere Alternative https://github.com/lucasg/Dependencies angewendet auf qsqlmysql.dll weiterhelfen

The-VoyZ commented 1 year ago

Wie wurde der Pfad zur libmysql.dll in die PATH-Variable eingetragen?

C:\MySqlDriver das ist der Path den ich angegeben habe. Dort sind die 3 lib files drin. Im Python Folder habe ich dann halt die qsqlmysql.dll untergebracht wie angegeben.

Windows hatte ich Neu Gestartet danach. War auch mein erster verdacht das das zu Problemen führen könnte.

Der Dependency Walker hatt mir aufjedenfall was ausgespuckt. Anscheinend fehlt der Qt6Sql.dll und die QT6Core.dll Habe den Path dahin hinzugefügt und siehe da :

qt.core.library: "C:/Users/USER/AppData/Local/Programs/Python/Python311/Lib/site-packages/PyQt6/Qt6/plugins/sqldrivers/qsqlmysql.dll" loaded library Database Connected

💯 Du bist ein Held ! Ich danke dir so sehr !

The-VoyZ commented 1 year ago

For those who might have the Same problem as me even when importing every thing correctly and you stil got the same error. As from @thecodemonkey86 Suggested Try Using https://github.com/lucasg/Dependencies and see if the Qt6Sql.dll and the Qt6Core.dll is not loaded properly.

if that is the Case you need to add this to your path:

\Tools\QtCreator\bin (there are the files hiding) or \Tools\QtDesignStudio\bin Then the qsqlmysql.dll can be read correctly and it will work. It might be the Problem that i used Python 3.11 or Qt did not correctly got assigned to my Path.