Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Installation and Deployment
  4. QtSql Driver Not Loaded (using OSX)

QtSql Driver Not Loaded (using OSX)

Scheduled Pinned Locked Moved Unsolved Installation and Deployment
pyqtinstallationmysql
9 Posts 2 Posters 3.8k 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.
  • I Offline
    I Offline
    Iogogo
    wrote on last edited by Iogogo
    #1

    I am trying to use Qt to open a mysql database using Python. I am getting a

    driver not loaded
    

    error. I currently have PyQt installed on the system nad have just downloaded Qt Createor.

    db = QtSql.QSqlDatabase.addDatabase("QMYSQL")
    db.setHostName("localhost")
    db.setDatabaseName("raw_data")
    db.setUserName("root")
    db.setPassword("password")
    db.open()
    False
    

    I have read numerous examples here about linking issues that could potentially cause this, however I dont know how to link the files and paths together correctly to fix the issue.

    Any help would be appreciated. Thank you

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

      Hi and welcome to devnet,

      Do you have the MySQL client libraries installed ?

      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
      • I Offline
        I Offline
        Iogogo
        wrote on last edited by
        #3

        I have downloaded MySQL using homebrew and it is currently installed in

        file:///usr/local/opt/mysql/
        

        This is also the location where qt is installed as well in

        file:///usr/local/opt/qt/plugins/sqldrivers/
        

        Where currently I only see the libsqlite.dylib file and nothing else.

        In the file:///usr/local/opt/mysql/ I do see a list of clinets that are installed and these are

        • libmysqlclient.20.dylib

        • libmysqlclient.a

        • libmysqlclient.dylib

        • libmysqld.a

        • libmysqlservices.a

        However running the type -a mysql command in terminal results in

        mysql is /usr/local/bin/mysql
        

        Let me know if any more information is needed

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

          How did you install Qt ?

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

          I 1 Reply Last reply
          0
          • SGaistS SGaist

            How did you install Qt ?

            I Offline
            I Offline
            Iogogo
            wrote on last edited by
            #5

            @SGaist I used brew install to download qt. However, I have recently downloaded Qt from the qt website and have the following link available

            /users/USERNAME/Qt/5.5/clang_64/plugins/sqldrivers/
            

            Where I have the following list of drivers

            • libqsqlite_debug.dylib

            • libqsqlite.dylib

            • libqsqlmysql_debug.dylib

            • libqsqlmysql.dylib

            • libqsqlodbc_debug.dylib

            • libqsqlodbc.dylib

            • libqsqlpqsql_debug.dylib

            • libqsqlpsql.dylib

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

              Using the version installed through homebrew should have the MySQL plugin working already.

              As for the version you downloaded, please run tool -L on libqsqlmysql.dylib

              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
              • I Offline
                I Offline
                Iogogo
                wrote on last edited by
                #7

                After running otool -L I get the following message

                libqsqlmysql.dylib:
                	libqsqlmysql.dylib (compatibility version 0.0.0, current version 0.0.0)
                	/opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib (compatibility version 18.0.0, current version 18.0.0)
                	/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.5)
                	@rpath/QtSql.framework/Versions/5/QtSql (compatibility version 5.5.0, current version 5.5.1)
                	@rpath/QtCore.framework/Versions/5/QtCore (compatibility version 5.5.0, current version 5.5.1)
                	/System/Library/Frameworks/DiskArbitration.framework/Versions/A/DiskArbitration (compatibility version 1.0.0, current version 1.0.0)
                	/System/Library/Frameworks/IOKit.framework/Versions/A/IOKit (compatibility version 1.0.0, current version 275.0.0)
                	/usr/lib/libc++.1.dylib (compatibility version 1.0.0, current version 120.0.0)
                	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1213.0.0)
                
                1 Reply Last reply
                0
                • SGaistS Offline
                  SGaistS Offline
                  SGaist
                  Lifetime Qt Champion
                  wrote on last edited by
                  #8

                  I don't know if the MySQL 20 and 18 are completely compatible but one thing you can try before rebuilding the plugin is to use install_name_tool:

                  install_name_tool -change /opt/local/lib/mysql55/mysql/libmysqlclient.18.dylib /usr/local/bin/mysql/libmysqlclient.20.dylib

                  If you are experiencing anything funky using the plugin, then rebuild it.

                  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
                  • I Offline
                    I Offline
                    Iogogo
                    wrote on last edited by
                    #9

                    That is what I was thinking regarding the compatibility of the two versions, I will attempt the change and let you know

                    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