我在尝试实现多对多关系时遇到以下错误:
Was unable to import app Error: Neither 'Column' object nor 'Comparator' object has an attribute 'schema'
这是我的代码:
association_table = Table('association',
Column('geo_idx', Integer, ForeignKey('geo.idx')),
Column('container_idx', Integer, ForeignKey('container.idx'))
)
class Geo(Model):
idx = Column(Integer, unique=True, primary_key=True)
name = Column(String(64), unique=True, primary_key=False)
containers = relationship("Container",
secondary=association_table, lazy = "subquery",
backref=backref('geos', lazy=True))
def __repr__(self):
return self.name
class Container(Model):
idx = Column(Integer, unique=True, primary_key=True)
name = Column(String(64), unique=True, primary_key=False)
def __repr__(self):
return self.name
我做了一些谷歌搜索,大多数出现此错误的人都因为没有大写 Column 而得到它,但在这种情况下并非如此。任何指针将不胜感激。