QMYSQL Driver Not Loaded
-
Hi there
I am VERY new to python and even newer to PyQt5.
I tried Tkinter but found it limited however I was able to connect to my MySQL database. With PyQt5 it has been impossible. I get the error message “QMYSQL Driver not loaded”. I came across all kinds of complex solutions online which I didn’t understand. In one case I was told to download QT which I did but don’t understand why. There was also mention of “qmake ” , “otool” and other things that I have no clue what they mean.
Surely it should not be this difficult to connect to a DB. I’m afraid I may overwhelm my laptop or worse crash it trying to follow these incoherent solutions. I’m using Mac Big Sur, Python 3, PyQt5. I will be grateful for any help - it's been 5 days wrangling with this problem and I'm not knowledgeable enough to alter paths etc etc etc.
-
Hi and welcome to the forums.
The reason its a bit compicated is that Qt does not come with the actual driver for QMYSQL but only a plugin that can use the driver so
you are required to download the QMYSQL client libs for your platform (matching 32 bit or 64 bit) and then compile the Qt plugin so it uses your client driver.https://doc.qt.io/qtforpython/overviews/sql-driver.html
This is for PySide6 though. Not 100% sure its exactly the same for PyQt5 as its not a Qt company product.Note this is for Qt 6. if using another version please note that this uses cmake tool and the older version uses the qmake tool.
The SQlite database on the other hand comes fully included.
It seems py5 can talk to mysql directly
https://pypi.org/project/mysqlclient/But if you want to use Qt wrapper, you have to build it first.
-
Hi and welcome to devnet,
Are you tied to MySQL ?
If not, I would recommend switching to PostgreSQL which should have the plugin pre-built and also has a nice package that is easy to install on macOS.