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. PyQt5 and MySQL or Postgres
Qt 6.11 is out! See what's new in the release blog

PyQt5 and MySQL or Postgres

Scheduled Pinned Locked Moved Unsolved Qt for Python
3 Posts 3 Posters 1.6k Views 1 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.
  • G Offline
    G Offline
    Greg_ox
    wrote on last edited by
    #1

    Hi,

    I am new to the forum and to using PyQt5

    I am using PyCharm, Python 3.8 on windows 10, MySQL 8.0 CE, Postgres 13. QT 5.15.1.

    I wanted to experiment a bit with a database application. The example was made with SQlite, but I wanted to change this to either Postgres or MySQL, which are databases that I would like to use in the future for my needs. Now, after a few days of struggling, googling etc. I still do not know how to get this to work.

    When I try to open the connection to the database, I get a message 'Driver not loaded". In PyQt5, the MySQL driver is not even listed in available drivers. I am totally stuck. When I use mysql.connector, the connection is immediately established, but the problems are with QtSql.

    And I do not know anyone using PyQt with a database to get help!

    I would be grateful if someone could help me with this.

    JonBJ 1 Reply Last reply
    0
    • G Greg_ox

      Hi,

      I am new to the forum and to using PyQt5

      I am using PyCharm, Python 3.8 on windows 10, MySQL 8.0 CE, Postgres 13. QT 5.15.1.

      I wanted to experiment a bit with a database application. The example was made with SQlite, but I wanted to change this to either Postgres or MySQL, which are databases that I would like to use in the future for my needs. Now, after a few days of struggling, googling etc. I still do not know how to get this to work.

      When I try to open the connection to the database, I get a message 'Driver not loaded". In PyQt5, the MySQL driver is not even listed in available drivers. I am totally stuck. When I use mysql.connector, the connection is immediately established, but the problems are with QtSql.

      And I do not know anyone using PyQt with a database to get help!

      I would be grateful if someone could help me with this.

      JonBJ Offline
      JonBJ Offline
      JonB
      wrote on last edited by
      #2

      @Greg_ox
      Firstly, whenever you get 'Driver not loaded" message, set Windows environment variable via set QT_DEBUG_PLUGINS=1 and then run, you will diagnostic information about what Qt is looking for where.

      I used PyQt5 on an app for both Linux & Windows, but I was not responsible for getting it working on Windows. Under Linux you have to apt-get a Python/PyQt5 plug-in library for each database driver. You have to do the same under Windows, but I'm not sure of the names. I think the file you might need is qsqlmysql.dll, maybe in somewhere like C:\Python37\Lib\site-packages\PyQt5\Qt\plugins\sqldrivers\.

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

        Hi and welcome to devnet,

        You are likely using a recent version of PyQt5. Currently, the MySQL plugin is not provided anymore by the pre-built versions of Qt due to licensing changes from Oracle. If you want to keep things simple and since it looks like an option, go with PostgreSQL.

        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
        1

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved