Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct
PyQt5 and MySQL or Postgres
Greg_ox last edited by
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.
JonB last edited by
Firstly, whenever you get 'Driver not loaded" message, set Windows environment variable via
set QT_DEBUG_PLUGINS=1and 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-geta 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
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.