开发者

Problem after transaction commit failed

I inserted entity "a" into table with unique column content. Then

Db.driver().commitTransaction()

Then begin new transaction and repeated. Transaction failed. As I can g开发者_StackOverflowuess next action is automatic transacion rollback. Then I tried

Dlg.Table.model().select()

but it returned 0 rows (although there are several rows in table). 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜