Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for Python
  4. Don't understand why QPSQL plugin isn't working in PySide2 on Windows
Qt 6.11 is out! See what's new in the release blog

Don't understand why QPSQL plugin isn't working in PySide2 on Windows

Scheduled Pinned Locked Moved Solved Qt for Python
5 Posts 2 Posters 1.6k Views 2 Watching
  • 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.
  • A Offline
    A Offline
    adutzu89
    wrote on last edited by
    #1

    Hello,
    I am trying to open connection to PostgreSQL databse in a PySide2 application on a Windows 10 machine with no avail.
    At first I encountered the following error:

    QSqlDatabase: QPSQL driver not loaded
    QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
    

    The documentation here: https://doc.qt.io/qtforpython/overviews/sql-driver.html#how-to-build-the-qpsql-plugin-on-windows only says about nmake so I had to look for a solution with mingw compiler.
    After hours of searching on the internet on how to build using MinGW compiler, and different solutions with different errors I finally stumbled unto this: https://bugreports.qt.io/browse/QTBUG-58372.
    So I opened the psql.pro file, followed the comments instructions and the plugin compiled without any issues.
    I copied the plugins(both release and debug) in the plugins/sql directory of Qt installation but the error persisted so I copied the plugins(both release and debug) in the same directory as my application aswell, afterwards, I copied the libpq.dll from the PostgreSQL installation into the application directory.
    After doing all that I still getting the driver error.
    Commands used to build the plugins:

    cd %QTDIR%\5.12.4\Src\qtbase\src\plugins\sqldrivers\psql
    qmake "INCLUDEPATH+=C:/psql/include" "LIBS+=C:/psql/lib/libpq.lib" psql.pro
    mingw32-make
    

    Any ideeas as to why?

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

      Hi,

      Start your application with the QT_DEBUG_PLUGINS environment variable set to 1. It will show you information about what is happening with the loading of the plugins.

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

      A 2 Replies Last reply
      0
      • SGaistS SGaist

        Hi,

        Start your application with the QT_DEBUG_PLUGINS environment variable set to 1. It will show you information about what is happening with the loading of the plugins.

        A Offline
        A Offline
        adutzu89
        wrote on last edited by
        #3

        @SGaist

        Got keys from plugin meta data ("QPSQL7", "QPSQL")
        QFactoryLoader::QFactoryLoader() looking at "C:/Users/Verban Adrian/AppData/Local/Programs/Python/Python37-32/lib/site-packages/PySide2/plugins/sqldrivers/qsqlpsqld.dll"
        Found metadata in lib C:/Users/Verban Adrian/AppData/Local/Programs/Python/Python37-32/lib/site-packages/PySide2/plugins/sqldrivers/qsqlpsqld.dll, metadata=
        {
            "IID": "org.qt-project.Qt.QSqlDriverFactoryInterface",
            "MetaData": {
                "Keys": [
                    "QPSQL7",
                    "QPSQL"
                ]
            },
            "archreq": 1,
            "className": "QPSQLDriverPlugin",
            "debug": true,
            "version": 330752
        }
        
        
        "The plugin 'C:/Users/Verban Adrian/AppData/Local/Programs/Python/Python37-32/lib/site-packages/PySide2/plugins/sqldrivers/qsqlpsqld.dll' uses incompatible Qt library. (Cannot mix debug and release libraries.)" 
                 not a plugin
        QFactoryLoader::QFactoryLoader() checking directory path "C:/Users/Verban Adrian/AppData/Local/Programs/Python/Python37-32/sqldrivers" ...
        Cannot load library C:\Users\Verban Adrian\AppData\Local\Programs\Python\Python37-32\lib\site-packages\PySide2\plugins\sqldrivers\qsqlpsql.dll: The specified procedure could not be found.
        QLibraryPrivate::loadPlugin failed on "C:/Users/Verban Adrian/AppData/Local/Programs/Python/Python37-32/lib/site-packages/PySide2/plugins/sqldrivers/qsqlpsql.dll" : "Cannot load library C:\\Users\\Verban Adrian\\AppData\\Local\\Programs\\Python\\Python37-32\\lib\\site-packages\\PySide2\\plugins\\sqldrivers\\qsqlpsql.dll: The specified procedure could not be found."
        QSqlDatabase: QPSQL driver not loaded
        QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7
        

        It goes for the plugin in PySide2. Guessing I need to build the plugin using that version of PySide2's source code?

        1 Reply Last reply
        0
        • SGaistS SGaist

          Hi,

          Start your application with the QT_DEBUG_PLUGINS environment variable set to 1. It will show you information about what is happening with the loading of the plugins.

          A Offline
          A Offline
          adutzu89
          wrote on last edited by adutzu89
          #4

          @SGaist I managed to do a workaround, downloaded PyQt5 and took their plugin for PostgreSQL and it works now....

          Will try today to download Qt5.13 source code(which is the version used in PySide2, from what I could gather), and the build the plugin with that version to see if it works.
          I have installed Qt 5.12.x at the moment, so I am guessing this could be the issue factor.

          Update:
          I didn't manage to download 5.13, had a lot of other stuff which kept my away from this task, will come back with a replay as soon as I am able.

          1 Reply Last reply
          0
          • A Offline
            A Offline
            adutzu89
            wrote on last edited by
            #5

            @SGaist

            I couldn't build with Qt 5.13.2

            Cannot read C:/Qt/5.13.2/Src/qtbase/src/plugins/sqldrivers/qtsqldrivers-config.pri: No such file or directory
            

            But I updated PySide2 to 5.13.2 and it works, so I will be marking this thread as solved.
            Thanks you.

            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