DeprecationWarning QSqlQueryModel.setQuery
-
Re: How to resolve this warning
I would like to be able to apply a parameterized query to QSqlQueryModel. However it looks like model.setQuery wants a string, not a query object. What's the best way to approach this?
I'm getting the following warning:
DeprecationWarning: Function: 'QSqlQueryModel.setQuery(const QSqlQuery & query)' is marked as deprecated, please check the documentation for more information.
Here's the test code:
def requery(self, customer_id): q = QSqlQuery() q.prepare(""" SELECT job_id, job_name, customer_id FROM job WHERE customer_id=? """) q.addBindValue(customer_id) q.exec() self._model.setQuery(q)
I understand from the referenced post above that this could cause memory leaks which is why it's marked for deprecation...
-
Hi,
Based on the documentation, I would say that it's rather at the binding level that it should be fixed. You can still use QSqlQuery with QSqlQueryModel.
-
@BamboozledBaboon yes. By the way, which version of PySide6 are you using ?
-
Then you should check the bug report system to see if there's something related and if not open a new ticket so it gets fixed.
-
Thanks !
Don't forget to post a link to the issue so it's easier to find.
-
@SGaist As requested https://bugreports.qt.io/browse/PYSIDE-2394
-
Thanks !