我有以下代码:
class Request(BaseMixin, Base):
id = Column(Integer, primary_key=True)
title = Column(String(30))
servers = association_proxy('request_servers','server')
class Server(BaseMixin, Base):
ip = Column(String(30), primary_key=True, autoincrement=False)
status = Column(String(15))
class Request2Server(AssocBaseMixin, Base):
request_id_fk = Column(Integer, ForeignKey('request.id'), primary_key=True)
server_ip_fk = Column(String(30), ForeignKey('server.ip'), primary_key=True)
request = relationship('Request', backref=backref('request_servers'))
server = relationship('Server')
注意-mixins只是设置表名
执行时:
request1 = Request(scan_title='tttt',ip='10.0.1.1')
server1 = Server(ip='30.0.1.3',server_id_fk=9)
request1.servers.append(server1)
它生成:
TypeError: init ()接受1个位置参数,但给出了2个
任何建议如何解决此问题?
谢谢 贾诺