0

I'm starting using MySQL following step by step a python manual but there is something wrong with the procedure or software I'm using. Here the code:

from PyQt5 import QtCore, QtGui, QtWidgets, QtSql

db = QtSql.QSqlDatabase.addDatabase('QMYSQL')
db.setHostName('localhost')
db.setDatabaseName('shopping')
db.setUserName('root')
db.setPassword('prova')
db.open()

I'm using Python 3.4(x64), PyQt GPL 5.5(x64), MySQL Server 8.0.11(x64), Connector/python(3.4) 8.0.11 on Windows 10.

Usually I run the file using MS-DOS prompt and write the code using notepad. Here the errors that come up:

QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers:
QSqlDatabase: an instance of QCoreApplication is required for loading driver plugins

The manual only says that I need MySQL server and MySQLdb module.

I have tried to follow the guidance here https://seppemagiels.com/blog/create-mysql-driver-qt5-windows but I have never used MinGW and never built a plugin. I`m confused

Max
  • 69
  • 1
  • 2
  • 7
  • You need to install the QMySql driver. In stackoverflow you have some answers like this https://stackoverflow.com/questions/44753724/pyqt-qsqldatabase-qmysql-driver-not-loaded/46872210#46872210 and https://stackoverflow.com/questions/17298849/installing-qmysql-driver – nacho May 30 '18 at 10:50
  • Possible duplicate of [Installing QMYSQL driver](https://stackoverflow.com/questions/17298849/installing-qmysql-driver) – nacho May 30 '18 at 10:51
  • Did you read and act upon the guidance given in the third error message? – ekhumoro May 30 '18 at 14:23
  • I'm still stuck. I've tried the guidance but nothing changed – Max Jun 12 '18 at 09:16

0 Answers0