[英]Problem after transaction commit failed
I inserted entity "a" into table with unique column content. 我将实体“ a”插入具有唯一列内容的表中。 Then 然后
Db.driver().commitTransaction()
Then begin new transaction and repeated. 然后开始新的交易并重复。 Transaction failed. 交易失败。 As I can guess next action is automatic transacion rollback. 我可以猜到,下一个动作是自动Transacion回滚。 Then I tried 然后我尝试
Dlg.Table.model().select()
but it returned 0 rows (although there are several rows in table). 但返回0行(尽管表中有几行)。 Why? 为什么? How to fix this? 如何解决这个问题?
EDIT: No, rollback have to be done manually. 编辑:不,回滚必须手动完成。
Only solution that I have found is using something like this function: 我发现的唯一解决方案正在使用类似此功能的东西:
def refresh_model(Dlg):
Dlg.Model = QSqlRelationalTableModel()
Dlg.Model.setTable(Dlg.TableName)
Dlg.Model.setEditStrategy(QSqlTableModel.OnManualSubmit)
for Col in range(len(DisplColNames[Dlg.TableName])):
Dlg.Model.setHeaderData( Col, Qt.Horizontal, DisplColNames[Dlg.TableName][Col])
Dlg.tvTable.setModel(Dlg.Model)
Dlg.Model.select()
But why I need to set new model after fail of transaction is unclear. 但是,为什么在交易失败后需要设置新模型尚不清楚。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.