QtSql Driver Not Loaded (using OSX)



  • 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


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    Do you have the MySQL client libraries installed ?



  • 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


  • Lifetime Qt Champion

    How did you install Qt ?



  • @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


  • Lifetime Qt Champion

    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



  • 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)
    

  • Lifetime Qt Champion

    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.



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


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.