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. [Solved] Unable to access low-level MySQL drivers in 5.3.1

[Solved] Unable to access low-level MySQL drivers in 5.3.1

Scheduled Pinned Locked Moved General and Desktop
5 Posts 2 Posters 1.6k 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.
  • redBeardR Offline
    redBeardR Offline
    redBeard
    wrote on last edited by
    #1

    I have a Windows-based application created with Qt 4.7 that uses MySQL database. Works well. The application can (optionally) use an embedded version of MySQL. That also works well. That bit of code uses the low-level MySQL drivers to connect to the DB. All other DB access code is the same.

    Now I'm trying to upgrade Qt to 5.3.1 and having problems with access to the MySQL low-level stuff in Qt.

    I build my version of Qt from sources.

    For my shared debug version of Qt 5.3.1 I used the following steps from a CMD shell. Note the 'CD' is actually 'percent CD percent' but I can't get this viewer to display those characters correctly...

    @

    cd c:\programs\qt (this directory contains the '5.3.1-base'
    source directory)
    mkdir 5.3.1-dd
    cd 5.3.1-dd
    ..\5.3.1-base\configure.bat -prefix CD\qtbase -debug -shared ^
    -qt-sql-mysql -no-compile-examples -qt-sql-odbc ^
    -opengl desktop -qt-style-windowsvista ^
    -no-rtti -no-icu -mp -saveconfig dd ^
    -I C:\Programs\MySQL\MySQLServer5.1\include ^
    -L C:\Programs\MySQL\MySQLServer5.1\lib\opt
    @

    That builds.

    Now the code that accesses the low-level MySQL drivers (needed for the embedded version) tries to include:

    @
    #include <qsql_mysql.h>
    #include <mysql.h>
    @

    Unfortunately, my '5.3.1-dd' structure doesn't contain the 'qsql_mysql.h' file anywhere.

    I see there's a 'qsql_mysql_p.sql' file in '5.3.1-base\qtbase\src\sql\drivers\mysql'.

    Hmmmm. Is support for accessing the low level MySQL drivers still available in 5.3?

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi and welcome to devnet,

      Yes it is, it's qsql_mysql_p.h. It's a private api header, so if you want to use it you need to add something like

      @QT += sql-private@

      Be aware since it's a private API it can completely change anytime without any warning.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • redBeardR Offline
        redBeardR Offline
        redBeard
        wrote on last edited by
        #3

        I think that did it. my model library linked. Thanks. Now on to other problems....

        I changed my .pro file to say:

        @QT += sql sql-private@

        and seems to have just added the following '-I' options to the INCPATH in the Makefile:
        @
        -I"C:\Programs\Qt\5.3.1-base\qtbase\include\QtSql\5.3.1"
        -I"C:\Programs\Qt\5.3.1-base\qtbase\include\QtSql\5.3.1\QtSql"
        @

        But I see the private SQL headers are actually in:
        @
        -I"C:\Programs\Qt\5.3.1-base\qtbase\include\QtSql\5.3.1\QtSql\private"
        @

        soooo, I just changed my header reference from:

        @
        #include <qsql_mysql.h>
        @

        to:

        @

        if QT_VERSION >= 0x050300

        include <private/qsql_mysql_p.h>

        else

        include <qsql_mysql.h>

        endif

        @

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          That's correct and expected, this has also the advantage of reminding you that you are doing something that can be dangerous ;)

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • redBeardR Offline
            redBeardR Offline
            redBeard
            wrote on last edited by
            #5

            Maybe, and that's a parking lot discussion.... If you look at the various (public) QtSQL classes n methods, one can easily use the lower-level classes. And, one needs to for embedded MySQL.

            In any case, thanks again. And once I get my app working in this environment, I'll mark this thread as [solved].

            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