Aug-06-2021, 08:34 AM
(Aug-05-2021, 07:38 PM)deanhystad Wrote: How about posting your code before you give up. Maybe you are making a little mistake that is easy to fix.
Hi i deanhystad - you're right to ask for the snippet. Been banging my head against
a wall and jus got frustrated. see code snippet below (i'm trying to test the connection object):
from PyQt5 import QtSql from PyQt5.QtGui import * from PyQt5.QtWidgets import * from PyQt5.QtCore import * from PyQt5.QtSql import * import sys def search(): mydb = QtSql.QSqlDatabase.addDatabase("QMySQL") mydb.setHostName("localhost") mydb.setUserName("root") mydb.setPassword("pioneer1") mydb.setDatabaseName("FriqueDB") mydb.open() if mydb.open(): print('database is opened') else: print('database not opened') btn1 =QPushButton(win) btn1.setText('Search') btn1.move(370,210) btn1.show() btn1.clicked.connect(search) win.show() sys.exit(app.exec_())This is the output:
Error:QSqlDatabase: QMySQL driver not loaded
QSqlDatabase: available drivers: QSQLITE QODBC QODBC3 QPSQL QPSQL7