Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. MySQL/MariaDB connector driver building Qt 6 Windows 10
Forum Updated to NodeBB v4.3 + New Features

MySQL/MariaDB connector driver building Qt 6 Windows 10

Scheduled Pinned Locked Moved General and Desktop
25 Posts 3 Posters 3.9k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P paokaras98

    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..
    qt.png

    jsulmJ Offline
    jsulmJ Offline
    jsulm
    Lifetime Qt Champion
    wrote on last edited by
    #2

    @paokaras98 said in MySQL&#x2F;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.

    https://forum.qt.io/topic/113070/qt-code-of-conduct

    P 1 Reply Last reply
    2
    • P Offline
      P Offline
      paokaras98
      wrote on last edited by paokaras98
      #3

      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

      qt.png
      dep.png

      1 Reply Last reply
      0
      • jsulmJ jsulm

        @paokaras98 said in MySQL&#x2F;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.

        P Offline
        P Offline
        paokaras98
        wrote on last edited by
        #4

        @jsulm said in MySQL&#x2F;MariaDB connector driver building Qt 6 Windows 10:

        @paokaras98 said in MySQL&#x2F;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

        Christian EhrlicherC 1 Reply Last reply
        0
        • P paokaras98

          @jsulm said in MySQL&#x2F;MariaDB connector driver building Qt 6 Windows 10:

          @paokaras98 said in MySQL&#x2F;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

          Christian EhrlicherC Offline
          Christian EhrlicherC Offline
          Christian Ehrlicher
          Lifetime Qt Champion
          wrote on last edited by
          #5

          With what compiler is your pyqt stuff compiled? You can not mix MSVC and MinGW.

          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
          Visit the Qt Academy at https://academy.qt.io/catalog

          P 1 Reply Last reply
          0
          • Christian EhrlicherC Christian Ehrlicher

            With what compiler is your pyqt stuff compiled? You can not mix MSVC and MinGW.

            P Offline
            P Offline
            paokaras98
            wrote on last edited by paokaras98
            #6

            @Christian-Ehrlicher said in MySQL&#x2F;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 :(
            ms.png

            Christian EhrlicherC 1 Reply Last reply
            0
            • P paokaras98

              @Christian-Ehrlicher said in MySQL&#x2F;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 :(
              ms.png

              Christian EhrlicherC Offline
              Christian EhrlicherC Offline
              Christian Ehrlicher
              Lifetime Qt Champion
              wrote on last edited by
              #7

              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.

              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
              Visit the Qt Academy at https://academy.qt.io/catalog

              P 1 Reply Last reply
              1
              • Christian EhrlicherC Christian Ehrlicher

                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.

                P Offline
                P Offline
                paokaras98
                wrote on last edited by paokaras98
                #8

                @Christian-Ehrlicher said in MySQL&#x2F;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 EhrlicherC 1 Reply Last reply
                0
                • P paokaras98

                  @Christian-Ehrlicher said in MySQL&#x2F;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 EhrlicherC Offline
                  Christian EhrlicherC Offline
                  Christian Ehrlicher
                  Lifetime Qt Champion
                  wrote on last edited by
                  #9

                  @paokaras98 said in MySQL&#x2F;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).

                  Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                  Visit the Qt Academy at https://academy.qt.io/catalog

                  P 1 Reply Last reply
                  0
                  • Christian EhrlicherC Christian Ehrlicher

                    @paokaras98 said in MySQL&#x2F;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).

                    P Offline
                    P Offline
                    paokaras98
                    wrote on last edited by paokaras98
                    #10

                    @Christian-Ehrlicher said in MySQL&#x2F;MariaDB connector driver building Qt 6 Windows 10:

                    @paokaras98 said in MySQL&#x2F;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 EhrlicherC 1 Reply Last reply
                    0
                    • P paokaras98

                      @Christian-Ehrlicher said in MySQL&#x2F;MariaDB connector driver building Qt 6 Windows 10:

                      @paokaras98 said in MySQL&#x2F;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 EhrlicherC Offline
                      Christian EhrlicherC Offline
                      Christian Ehrlicher
                      Lifetime Qt Champion
                      wrote on last edited by
                      #11

                      You have to make sure all needed depent dlls are in the PATH.

                      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                      Visit the Qt Academy at https://academy.qt.io/catalog

                      P 1 Reply Last reply
                      1
                      • Christian EhrlicherC Christian Ehrlicher

                        You have to make sure all needed depent dlls are in the PATH.

                        P Offline
                        P Offline
                        paokaras98
                        wrote on last edited by
                        #12

                        @Christian-Ehrlicher said in MySQL&#x2F;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 EhrlicherC 1 Reply Last reply
                        0
                        • P paokaras98

                          @Christian-Ehrlicher said in MySQL&#x2F;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 EhrlicherC Offline
                          Christian EhrlicherC Offline
                          Christian Ehrlicher
                          Lifetime Qt Champion
                          wrote on last edited by
                          #13

                          E.g. with DependencyWalker or it's successor Dependencies. You need at least the mysql or mariadb dlls

                          Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                          Visit the Qt Academy at https://academy.qt.io/catalog

                          P 1 Reply Last reply
                          1
                          • Christian EhrlicherC Christian Ehrlicher

                            E.g. with DependencyWalker or it's successor Dependencies. You need at least the mysql or mariadb dlls

                            P Offline
                            P Offline
                            paokaras98
                            wrote on last edited by
                            #14

                            @Christian-Ehrlicher said in MySQL&#x2F;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 EhrlicherC 1 Reply Last reply
                            0
                            • P paokaras98

                              @Christian-Ehrlicher said in MySQL&#x2F;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 EhrlicherC Offline
                              Christian EhrlicherC Offline
                              Christian Ehrlicher
                              Lifetime Qt Champion
                              wrote on last edited by
                              #15

                              @paokaras98 said in MySQL&#x2F;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.

                              Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                              Visit the Qt Academy at https://academy.qt.io/catalog

                              P 1 Reply Last reply
                              0
                              • Christian EhrlicherC Christian Ehrlicher

                                @paokaras98 said in MySQL&#x2F;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.

                                P Offline
                                P Offline
                                paokaras98
                                wrote on last edited by
                                #16

                                @Christian-Ehrlicher said in MySQL&#x2F;MariaDB connector driver building Qt 6 Windows 10:

                                @paokaras98 said in MySQL&#x2F;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
                                path.png

                                marialib.png
                                reko.png
                                What is the next step :p. Iam feeling silly since I follow all the steps and stills doesnt work

                                1 Reply Last reply
                                0
                                • P Offline
                                  P Offline
                                  paokaras98
                                  wrote on last edited by
                                  #17

                                  YESSSSSSSSSSSSSSSSS FINALLY WORKED. I copied libmaria, qmysql, qmysqld dlls into

                                  C:\Users\panos\AppData\Roaming\Python\Python310\site-packages\PyQt6\Qt6\plugins\sqldrivers
                                  
                                  jsulmJ 1 Reply Last reply
                                  0
                                  • P paokaras98

                                    YESSSSSSSSSSSSSSSSS FINALLY WORKED. I copied libmaria, qmysql, qmysqld dlls into

                                    C:\Users\panos\AppData\Roaming\Python\Python310\site-packages\PyQt6\Qt6\plugins\sqldrivers
                                    
                                    jsulmJ Offline
                                    jsulmJ Offline
                                    jsulm
                                    Lifetime Qt Champion
                                    wrote on last edited by
                                    #18

                                    @paokaras98 said in MySQL&#x2F;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.

                                    https://forum.qt.io/topic/113070/qt-code-of-conduct

                                    P 1 Reply Last reply
                                    0
                                    • jsulmJ jsulm

                                      @paokaras98 said in MySQL&#x2F;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.

                                      P Offline
                                      P Offline
                                      paokaras98
                                      wrote on last edited by
                                      #19

                                      @jsulm said in MySQL&#x2F;MariaDB connector driver building Qt 6 Windows 10:

                                      @paokaras98 said in MySQL&#x2F;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''

                                      jsulmJ 1 Reply Last reply
                                      0
                                      • P paokaras98

                                        @jsulm said in MySQL&#x2F;MariaDB connector driver building Qt 6 Windows 10:

                                        @paokaras98 said in MySQL&#x2F;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''

                                        jsulmJ Offline
                                        jsulmJ Offline
                                        jsulm
                                        Lifetime Qt Champion
                                        wrote on last edited by
                                        #20

                                        @paokaras98 said in MySQL&#x2F;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.

                                        https://forum.qt.io/topic/113070/qt-code-of-conduct

                                        P 1 Reply Last reply
                                        1
                                        • jsulmJ jsulm

                                          @paokaras98 said in MySQL&#x2F;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.
                                          P Offline
                                          P Offline
                                          paokaras98
                                          wrote on last edited by
                                          #21

                                          @jsulm said in MySQL&#x2F;MariaDB connector driver building Qt 6 Windows 10:

                                          @paokaras98 said in MySQL&#x2F;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.

                                          I understand your point, but what if I want to distribute my app to another computer and this computer does not have any db server installed. Could the database connect and work successfully only with client libraries even if none dbms server software is installed?

                                          jsulmJ 1 Reply Last reply
                                          0

                                          • Login

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • Users
                                          • Groups
                                          • Search
                                          • Get Qt Extensions
                                          • Unsolved