2021年3月13日星期六

sqlalchemy relationship leads to Multiple classes found for path "Name" in the registry

this is my code:

class Relationp(db.Model):      id = db.Column(db.Integer, primary_key=True)      child = db.relationship('Relationc')      __table_args__ = {'extend_existing': True}        def __repr__(self):          return "<p {}>".format(self.id)    class Relationc(db.Model):      id= db.Column(db.Integer, primary_key=True)      parent_id = db.Column(db.Integer, db.ForeignKey('relationp.id'))      __table_args__ = {'extend_existing': True}        def __repr__(self):          return "<c {}>".format(self.id)        print(Relationc.query.all())  

after running, i get the error:

Multiple classes found for path "Relationc" in the registry of this declarative base. Please use a fully module-qualified path.  

please let me know what leads to this and how to fix it. thanks!

https://stackoverflow.com/questions/66620999/sqlalchemy-relationship-leads-to-multiple-classes-found-for-path-name-in-the-r March 14, 2021 at 12:07PM

没有评论:

发表评论