PyQt5 MYSQL driver not loaded windows

Heads up! You've already completed this tutorial.

eaperezdelgado6031 | 2020-08-19 14:40:11 UTC | #1

Hello I am having this issue when I am trying to connect to a local mysql database using QSqlDatabase.addDatabe method. I've found this issue in a lot of forums, but with no clear solutions especially as most of them as for C++ and I can't understand the Qt documentarion on mysql drivers, (there are no really good documentation for PyQt)

This is error I get when try to run my python script:

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

I am using Windows 10, MySql 8, Python 3.7, PyQt 5.9 and PyQt-tools 5.9 (I am using this version of PyQt because I am also using fbs, the fbs manual says it works better with that version of PyQt5)

This is a useful statement that I read in stackoverflow but it is for C++: """ Remember that qsqlmysql plugin is basically a qt interface that uses mysql-C connector methods. But unfortunately this connector does not distributed with Qt, so you should provide it by yourself. """

In summary I'd like to know which are missing files (.dll, .so, .lib)? where do I get them? and where do I copy them? in case for Python

Please if you need my script, but it is simple: 1) I try to connect using QSqlDatabase.addDatabase('QMYSQL') 2) Instatiate a QSqlTableModel that uses that db connection and sets a single table of that database. 3) Display this single table in a QTableView.

1:1 Coaching & Tutoring for your Python GUIs project
Martin Fitzpatrick Python GUIs Coaching & Training
60 mins ($195) Book Now

1:1 Python GUIs Coaching & Training

Comprehensive code reviewBugfixes & improvements • Maintainability advice and architecture improvements • Design and usability assessment • Suggestions and tips to expand your knowledgePackaging and distribution help for Windows, Mac & Linux • Find out more.

Thanks in advance for your help

Bring Your PyQt/PySide Application to Market — Stuck in development hell? I'll help you get your project focused, finished and released. Benefit from years of practical experience releasing software with Python.

Find out More


Packaging Python Applications with PyInstaller by Martin Fitzpatrick — This step-by-step guide walks you through packaging your own Python applications from simple examples to complete installers and signed executables.

More info Get the book

Well done, you've finished this tutorial! Mark As Complete
[[ user.completed.length ]] completed [[ user.streak+1 ]] day streak
Martin Fitzpatrick

PyQt5 MYSQL driver not loaded windows was written by Martin Fitzpatrick.

Martin Fitzpatrick has been developing Python/Qt apps for 8 years. Building desktop applications to make data-analysis tools more user-friendly, Python was the obvious choice. Starting with Tk, later moving to wxWidgets and finally adopting PyQt. Martin founded PythonGUIs to provide easy to follow GUI programming tutorials to the Python community. He has written a number of popular Python books on the subject.