报错信息如下:
(pymysql.err.IntegrityError) (1452, u'Cannot add or update a child row: a foreign key constraint fails
解决办法:
SET FOREIGN_KEY_CHECKS = 0; # 临时取消外键约束
SET FOREIGN_KEY_CHECKS = 1; # 开启外键约束
添加之前临时取消一下外键约束,添加好数据之后,再将外键约束改回来就可以啦!
标签:fails,constraint,外键,约束,报错,key From: https://www.cnblogs.com/lemperor/p/16708034.html