pythonpyqt5qsqlrelationaltablemodel

How to update or insert into related table in a qsqlrelationaltablemodel


I have this relational model

rel_model = QSqlRelationalTableModel(self, connectDB)
rel_model.setTable("person")
rel_model.setRelation(1, QSqlRelation("email", "id", "emailAddres"))
rel_model.select()

Main table holds data from the person and the related table several emails from that person. A one to many relationships. How can I update or insert emails now? I know there are insert queries but I guess there must be a way to work directly with the model.


Solution

  • i found a good example in this

    https://github.com/ghosert/VimProject/blob/master/pyqt/book_samples/chap15/phonelog-fk.pyw