MySQL/MariaDB connector driver building Qt 6 Windows 10
-
Hello,
I live a nightmare the last few days because I cant prepare the files for MySQL/MariaDB driver . I am really struggling to understand this https://doc.qt.io/qtforpython-6/overviews/sql-driver.html#building-the-drivers.
Note that Iam using Python, so its more difficult to find something relatively same with the internet resources. For my Qt 6 version there is not Src folder nor qtbase folder, as Qt 5.15.
I dont understand in which directory should I run these commands as well as which terminal(windows cmd, any Qt specific terminal, qtmake.exe terminal etc).mkdir build-sqldrivers cd build-sqldrivers qt-cmake -G Ninja <qt_installation_path>\Src\qtbase\src\plugins\sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>\<platform> -DMySQL_INCLUDE_DIR="C:\mysql-8.0.22-winx64\include" -DMySQL_LIBRARY="C:\mysql-8.0.22-winx64\lib\libmysql.lib" cmake --build . cmake --install .
Can someone explain me step by step all the process as I could be a silly person. I attach some pictures showing the Qt6 folder structure. You are my last chance, please help..
-
-
Hello,
I live a nightmare the last few days because I cant prepare the files for MySQL/MariaDB driver . I am really struggling to understand this https://doc.qt.io/qtforpython-6/overviews/sql-driver.html#building-the-drivers.
Note that Iam using Python, so its more difficult to find something relatively same with the internet resources. For my Qt 6 version there is not Src folder nor qtbase folder, as Qt 5.15.
I dont understand in which directory should I run these commands as well as which terminal(windows cmd, any Qt specific terminal, qtmake.exe terminal etc).mkdir build-sqldrivers cd build-sqldrivers qt-cmake -G Ninja <qt_installation_path>\Src\qtbase\src\plugins\sqldrivers -DCMAKE_INSTALL_PREFIX=<qt_installation_path>\<platform> -DMySQL_INCLUDE_DIR="C:\mysql-8.0.22-winx64\include" -DMySQL_LIBRARY="C:\mysql-8.0.22-winx64\lib\libmysql.lib" cmake --build . cmake --install .
Can someone explain me step by step all the process as I could be a silly person. I attach some pictures showing the Qt6 folder structure. You are my last chance, please help..
@paokaras98 said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
For my Qt 6 version there is not Src folder nor qtbase folder
You need to download Qt source code!
You can use Qt Maintenance Tool in your Qt installation to also install Qt source code. -
Hello jsulm and thanks for your clear response.
Now, I notice a small improvement. Lets boil down all the steps I ' ve done so far.- I have mingw_64 platform (with msvc2019_64 just did not compile)
- Qt version 6.4.2
- The folder with the generated qsqlmysql(I think these qsqlmyslq files are the reason for my nightmares) is located at
C:\Qt\6.4.2\mingw_64\build-sqldrivers\plugins\sqldrivers
. I attach a particular image. - The dependancy walker for my qsqlmysql.dll indicates dependancy on msvcrt.dll as shown in the image below. Given that msvc2019_64 cant work in my case, is it the only way to get a functional connection? or mingw makes the job?
- Now, suppose my pyqt project (with guis, functions etc) is located at a destination lets say
C:/myproject/
. The question is whether should I copy the qsqlmysql files from plugins to the project folder. In any case, after the qsqlmysql generation what have to do with these, in order, finally to get a working Mariadb/mysql connection with my application? (Leaving all files as they were generated gives me QMYSQL not found when i try to addDatabase in my python project)
Thank you
-
@paokaras98 said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
For my Qt 6 version there is not Src folder nor qtbase folder
You need to download Qt source code!
You can use Qt Maintenance Tool in your Qt installation to also install Qt source code.@jsulm said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
@paokaras98 said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
For my Qt 6 version there is not Src folder nor qtbase folder
You need to download Qt source code!
You can use Qt Maintenance Tool in your Qt installation to also install Qt source code.Also my MariaDB dist is 10.11
-
@jsulm said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
@paokaras98 said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
For my Qt 6 version there is not Src folder nor qtbase folder
You need to download Qt source code!
You can use Qt Maintenance Tool in your Qt installation to also install Qt source code.Also my MariaDB dist is 10.11
With what compiler is your pyqt stuff compiled? You can not mix MSVC and MinGW.
-
With what compiler is your pyqt stuff compiled? You can not mix MSVC and MinGW.
@Christian-Ehrlicher said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
With what compiler is your pyqt stuff compiled? You can not mix MSVC and MinGW.
Hello Christian and thanks for your interest. How did you assume that i have mixed msvc with mingw? Also how can i see my pyqt stuff compiler? I use visual studio code for development, no QtCreator
Also, basically, I do not understand the following things and how they work: the msvc, mingw for my Qt, qsqlmysql.dll and the msvc, mingw for pyqt
Iam one step before give up and install SQLite :P , you are my last hope
OOh wait i think i found it, i think that the compiler is msvc :(
-
@Christian-Ehrlicher said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
With what compiler is your pyqt stuff compiled? You can not mix MSVC and MinGW.
Hello Christian and thanks for your interest. How did you assume that i have mixed msvc with mingw? Also how can i see my pyqt stuff compiler? I use visual studio code for development, no QtCreator
Also, basically, I do not understand the following things and how they work: the msvc, mingw for my Qt, qsqlmysql.dll and the msvc, mingw for pyqt
Iam one step before give up and install SQLite :P , you are my last hope
OOh wait i think i found it, i think that the compiler is msvc :(
So you have to compile the plugin also with msvc and the exact same Qt version as PyQt.
Ask the PyQt folks which compiler they use if you're unsure. -
So you have to compile the plugin also with msvc and the exact same Qt version as PyQt.
Ask the PyQt folks which compiler they use if you're unsure.@Christian-Ehrlicher said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
So you have to compile the plugin also with msvc and the exact same Qt version as PyQt.
Ask the PyQt folks which compiler they use if you're unsure.After reading so much cases, I think that both works but the important thing is to have compiled pyqt/qt and sql drivers with the same compiler.
Regarding Qt/Pyqt Compile , is it adequate just to download and install Qt checking the msvx2019_64 compiler, or should also use nmake command when building sql drivers
I dont understand your advice ''you have to compile the plugin with th same Qt version as PyQt?'" Do you have any command in your mind? -
@Christian-Ehrlicher said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
So you have to compile the plugin also with msvc and the exact same Qt version as PyQt.
Ask the PyQt folks which compiler they use if you're unsure.After reading so much cases, I think that both works but the important thing is to have compiled pyqt/qt and sql drivers with the same compiler.
Regarding Qt/Pyqt Compile , is it adequate just to download and install Qt checking the msvx2019_64 compiler, or should also use nmake command when building sql drivers
I dont understand your advice ''you have to compile the plugin with th same Qt version as PyQt?'" Do you have any command in your mind?@paokaras98 said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
Do you have any command in your mind?
No but when PyQt is compiled against e.g. Qt6.3 your plugin must also be compiled with Qt 6.3 (or lower).
-
@paokaras98 said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
Do you have any command in your mind?
No but when PyQt is compiled against e.g. Qt6.3 your plugin must also be compiled with Qt 6.3 (or lower).
@Christian-Ehrlicher said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
@paokaras98 said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
Do you have any command in your mind?
No but when PyQt is compiled against e.g. Qt6.3 your plugin must also be compiled with Qt 6.3 (or lower).
I tried to copy the generated qsqlmysql.dll to the PyQt6 plugins/sqldrivers folder and then when I run my Python application, NOW MariaDB and MYSQL drivers are available BUT NOT loaded :(
QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL ['QSQLITE', 'QMARIADB', 'QMYSQL', 'QODBC', 'QPSQL']
I think that we are close to the solution, arent we?
-
@Christian-Ehrlicher said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
@paokaras98 said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
Do you have any command in your mind?
No but when PyQt is compiled against e.g. Qt6.3 your plugin must also be compiled with Qt 6.3 (or lower).
I tried to copy the generated qsqlmysql.dll to the PyQt6 plugins/sqldrivers folder and then when I run my Python application, NOW MariaDB and MYSQL drivers are available BUT NOT loaded :(
QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMARIADB QMYSQL QODBC QPSQL ['QSQLITE', 'QMARIADB', 'QMYSQL', 'QODBC', 'QPSQL']
I think that we are close to the solution, arent we?
You have to make sure all needed depent dlls are in the PATH.
-
You have to make sure all needed depent dlls are in the PATH.
@Christian-Ehrlicher said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
You have to make sure all needed depent dlls are in the PATH.
And how can I identify which dlls are depent? I know how to check the PATH variables
-
@Christian-Ehrlicher said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
You have to make sure all needed depent dlls are in the PATH.
And how can I identify which dlls are depent? I know how to check the PATH variables
E.g. with DependencyWalker or it's successor Dependencies. You need at least the mysql or mariadb dlls
-
E.g. with DependencyWalker or it's successor Dependencies. You need at least the mysql or mariadb dlls
@Christian-Ehrlicher said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
E.g. with DependencyWalker or it's successor Dependencies. You need at least the mysql or mariadb dlls
I have each one in their specific connectors. Apart from there should I copy these dlls, into another folder?
-
@Christian-Ehrlicher said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
E.g. with DependencyWalker or it's successor Dependencies. You need at least the mysql or mariadb dlls
I have each one in their specific connectors. Apart from there should I copy these dlls, into another folder?
@paokaras98 said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
Apart from there should I copy these dlls, into another folder?
You have to make sure all needed depent dlls are in the PATH.
-
@paokaras98 said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
Apart from there should I copy these dlls, into another folder?
You have to make sure all needed depent dlls are in the PATH.
@Christian-Ehrlicher said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
@paokaras98 said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
Apart from there should I copy these dlls, into another folder?
You have to make sure all needed depent dlls are in the PATH.
I used the prebuilt .dlls from here https://github.com/thecodemonkey86/qt_mysql_driver
And then followed without any error the commands forMSVC2019, nothing worked. In the end the Driver is available but not loaded.
As you can see in the following images, I have set the libmariadb.lib in enviroment variables and /lib and /include subdirs into PATH.
Finally the dependecies for qsqlmysql.dll are fulfilled since I have compiled with MSVC
What is the next step :p. Iam feeling silly since I follow all the steps and stills doesnt work -
YESSSSSSSSSSSSSSSSS FINALLY WORKED. I copied libmaria, qmysql, qmysqld dlls into
C:\Users\panos\AppData\Roaming\Python\Python310\site-packages\PyQt6\Qt6\plugins\sqldrivers
-
YESSSSSSSSSSSSSSSSS FINALLY WORKED. I copied libmaria, qmysql, qmysqld dlls into
C:\Users\panos\AppData\Roaming\Python\Python310\site-packages\PyQt6\Qt6\plugins\sqldrivers
@paokaras98 said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
qmysqld
This one is the debug version and I don't think you need it as you're probably not going to debug it.
-
@paokaras98 said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
qmysqld
This one is the debug version and I don't think you need it as you're probably not going to debug it.
@jsulm said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
@paokaras98 said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
qmysqld
This one is the debug version and I don't think you need it as you're probably not going to debug it.
I thought that mysqld.dll has to do with mysqld.exe, because now Iam wondering, how my database could wok in another computer, where no mariadb server etc. files are installed, so we would like to have the mysqld.exe ''representative''
-
@jsulm said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
@paokaras98 said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
qmysqld
This one is the debug version and I don't think you need it as you're probably not going to debug it.
I thought that mysqld.dll has to do with mysqld.exe, because now Iam wondering, how my database could wok in another computer, where no mariadb server etc. files are installed, so we would like to have the mysqld.exe ''representative''
@paokaras98 said in MySQL/MariaDB connector driver building Qt 6 Windows 10:
mysqld.exe
What is this?
Clients do not need the server stuff, just deploy client libraries together with your application.And to precise what I mentioned before:
- qmysql.dll - this is the release build of the plug-in
- qmysqld - this is debug build of the plug-in
There is really no need to deploy release AND debug build of the plug-ins/libraries.