是否可以暂时禁用MySQL中的约束?
我有两个Django模型,每个都有一个指向另一个的外键。删除一个模型的实例将返回一个错误,因为外键约束:
cursor.execute("DELETE FROM myapp_item WHERE n = %s", n)
transaction.commit_unless_managed() #a foreign key constraint fails here
cursor.execute("DELETE FROM myapp_style WHERE n = %s", n)
transaction.commit_unless_managed()
是否有可能暂时禁用约束并删除?