我有三个表:倡导者,客户和事件。在事件表中,我有两个字段引用了两个来自主表和一个字段引用客户端的字段,当我尝试添加外键时,我得到这个不能添加外键约束错误。
create table advocate(
ida int(11) not null,
idk int(11) not null,
#...
primary key(ida, idk)
)engine = InnoDB default charset=utf8;
create table client(
jmb varchar(13) not null primary key
#...
)engine=InnoDB default charset=utf8;
create table event(
ida int(11) not null,
idk int(11) not null,
jmb varchar(13) not null,
#...
primary key(ida,idk,jmb),
foreign key(ida, idk)
references advocate(ida, idk)
on update cascade
on delete restrict,
foreign key(jmb)
references client.jmb
on update cascade
on delete restrict
)engine=InnoDB default charset=utf8;
答案 0 :(得分:1)
你可以尝试改变:
def function(object, a):
if name in object.__dict__:
setattr(object, a, 5)
到
__dict__