Pyqt Qsqldatabase: Qmysql Driver Not Loaded
I am trying to connect to a MySQL database using PyQt5 on Python 3.6 for 64-bit Windows. When I call QSqlDatabase.addDatabase('MYSQL') and run my utility, it shows up with this err
Solution 1:
It said driver available but you need to rebuid a new Mysql driver base on Qt Source code and Mysql Library.
Solution 2:
Same issue for me with Windows 10. I didn't investigate much about making the QMYSQL driver available in Windows 10, but here is a workaround :
- use QODBC driver (
QSqlDatabase.addDatabase('QODBC')
) - db.setDatabaseName(My_ODBC_source)
"My_ODBC_source" has to be created. On Windows 10:
- Install Mysql ODBC 5.x ANSI Driver (32 bits) (download)
- create a new user or machine ODBC data source named "My_ODBC_source" (see MySQL docs) You must provide ip address or mysql server name, user, password.So it does not have to be provided in your pyqt code.
Post a Comment for "Pyqt Qsqldatabase: Qmysql Driver Not Loaded"