QSqlQueryModel.setQuery() won´t accept strg
-
Hi everyone!
I have a problem handing over the query to the setQuery() function. According to the documentation, the synthax should be QSQlQueryModel.setQuery(query, db=QSqlDatabase).
That´s what I believe I do, but I get the error:
TypeError: descriptor 'setQuery' for 'PySide6.QtSql.QSqlQueryModel' objects doesn't apply to a 'str' objectHere´s the relevant code. There´s a lot of more code but it has nothing to do with the setQuery.
from PySide6.QtWidgets import QApplication, QMainWindow, QTableWidgetItem from PySide6 import QtSql, QtCore, QtGui, QtWidgets class Frm_Indications(QMainWindow, Ui_frmIndications): def __init__(self): super().__init__() self.setupUi(self) self.mod_Indication = QtSql.QSqlQueryModel def Search(self): self.mod_Indication.setQuery("SELECT * FROM qryIndication ", db = self.db_assess)
Hope anyone can help me what I do wrong... Many thanks!
Seamus
-
Solved: Missing parenthesis in
self.mod_Indication = QtSql.QSqlQueryModel
correct:
self.mod_Indication = QtSql.QSqlQueryModel() -
Hi everyone!
I have a problem handing over the query to the setQuery() function. According to the documentation, the synthax should be QSQlQueryModel.setQuery(query, db=QSqlDatabase).
That´s what I believe I do, but I get the error:
TypeError: descriptor 'setQuery' for 'PySide6.QtSql.QSqlQueryModel' objects doesn't apply to a 'str' objectHere´s the relevant code. There´s a lot of more code but it has nothing to do with the setQuery.
from PySide6.QtWidgets import QApplication, QMainWindow, QTableWidgetItem from PySide6 import QtSql, QtCore, QtGui, QtWidgets class Frm_Indications(QMainWindow, Ui_frmIndications): def __init__(self): super().__init__() self.setupUi(self) self.mod_Indication = QtSql.QSqlQueryModel def Search(self): self.mod_Indication.setQuery("SELECT * FROM qryIndication ", db = self.db_assess)
Hope anyone can help me what I do wrong... Many thanks!
Seamus
This post is deleted! -
Hi everyone!
I have a problem handing over the query to the setQuery() function. According to the documentation, the synthax should be QSQlQueryModel.setQuery(query, db=QSqlDatabase).
That´s what I believe I do, but I get the error:
TypeError: descriptor 'setQuery' for 'PySide6.QtSql.QSqlQueryModel' objects doesn't apply to a 'str' objectHere´s the relevant code. There´s a lot of more code but it has nothing to do with the setQuery.
from PySide6.QtWidgets import QApplication, QMainWindow, QTableWidgetItem from PySide6 import QtSql, QtCore, QtGui, QtWidgets class Frm_Indications(QMainWindow, Ui_frmIndications): def __init__(self): super().__init__() self.setupUi(self) self.mod_Indication = QtSql.QSqlQueryModel def Search(self): self.mod_Indication.setQuery("SELECT * FROM qryIndication ", db = self.db_assess)
Hope anyone can help me what I do wrong... Many thanks!
Seamus
@SeamusQDraide said in QSqlQueryModel.setQuery() won´t accept strg:
self.mod_Indication.setQuery("SELECT * FROM qryIndication ", db = self.db_assess)
What type is self.db_assess ?
-
@SeamusQDraide said in QSqlQueryModel.setQuery() won´t accept strg:
self.mod_Indication.setQuery("SELECT * FROM qryIndication ", db = self.db_assess)
What type is self.db_assess ?
It´s an SQlite db (self.database_assess is a str containing the path to the db):
self.db_assess = QtSql.QSqlDatabase.addDatabase("QSQLITE", self.database_assess) self.db_assess.setDatabaseName(programmpfad + self.database_assess) self.db_assess.open()
-
Solved: Missing parenthesis in
self.mod_Indication = QtSql.QSqlQueryModel
correct:
self.mod_Indication = QtSql.QSqlQueryModel() -