This commit is contained in:
ccppi 2024-07-26 15:56:30 +02:00
parent 5c580adf7f
commit 6e55415282

View File

@ -36,3 +36,22 @@ class SqlQueryModel_editable(QSqlQueryModel):
print(self.query().lastError().text()) print(self.query().lastError().text())
return result return result
return QSqlQueryModel.setData(self, index, value, role) return QSqlQueryModel.setData(self, index, value, role)
# view = QTableView()
#
# editables = {1 : ("UPDATE Manufacturers SET Country = '{}' WHERE Company = '{}'", 2)}
# model = SqlQueryModel_editable(editables)
# query = '''
# SELECT (comp.company || " " || cars.model) as Car,
# comp.Country,
# cars.company,
# (CASE WHEN cars.Year > 2000 THEN 'yes' ELSE 'no' END) as this_century
# from manufacturers comp left join cars
# on comp.company = cars.company
# '''
# q = QSqlQuery(query)
# model.setQuery(q)
# model.setFilter("cars.Company = 'VW'")
# view.setModel(model)
# view.hideColumn(2)