With this code:
db = QtSql.QSqlDatabase.addDatabase('QMYSQL') db.setHostName('localhost') db.setUserName('root') db.setPassword('1234') db.setDatabaseName('test') db.open() print(db.lastError().text()) The console displays the following:
python gui.py QSqlDatabase: QMYSQL driver not loaded QSqlDatabase: available drivers: QSQLITE QMYSQL QMYSQL3 QODBC QODBC3 QPSQL QPSQL7 Driver not loaded Driver not loaded The qsqlite.dll, qsqlmysql.dll, qsqlodbc.dll, qsqlpsql.dll libraries exist and are located in the
C: \ Python \ Lib \ site-packages \ PyQt5 \ Qt \ plugins \ sqldrivers
I use Windows 10 x64, Python 3.6.1, PyQt 5.8, MySql 5.7.
This question has already been asked here , but the solution that it contains, my problem is not solved.
What should I do to establish a connection with the database?