[Python] QSqlRelationalTableModel does not respect the foreign key rules in the database

Discussão em 'Python' iniciado por Stack, Dezembro 8, 2024.

  1. Stack

    Stack Membro Participativo

    I have a problem deleting data from a SQLite database. The problem is that data is deleted even if the database does not allow it. If I try to delete a record directly in the database, I get the message Error while deleting row from table exp_subcategory: FOREIGN KEY constraint failed. If I delete the same record from the data model with the command model.removeRow(row), the record is deleted without an error message being displayed. How can I stop this and prevent a record from being deleted that cannot be deleted according to the database?

    Thanks!

    Continue reading...

Compartilhe esta Página