Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Qt Academy Launch in California!

    Unsolved QtSql Driver Not Loaded (using OSX)

    Installation and Deployment
    pyqt installation mysql
    2
    9
    3286
    Loading More Posts
    • 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
      Iogogo last edited by Iogogo

      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 Reply Quote 0
      • SGaist
        SGaist Lifetime Qt Champion last edited by

        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 Reply Quote 0
        • I
          Iogogo last edited by

          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 Reply Quote 0
          • SGaist
            SGaist Lifetime Qt Champion last edited by

            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 Reply Quote 0
            • I
              Iogogo @SGaist last edited by

              @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 Reply Quote 0
              • SGaist
                SGaist Lifetime Qt Champion last edited by

                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 Reply Quote 0
                • I
                  Iogogo last edited by

                  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 Reply Quote 0
                  • SGaist
                    SGaist Lifetime Qt Champion last edited by

                    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 Reply Quote 0
                    • I
                      Iogogo last edited by

                      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 Reply Quote 0
                      • First post
                        Last post