SQLalchemy not find table for creating foreign key

前端 未结 3 619
别那么骄傲
别那么骄傲 2021-02-03 20:28

I have a problem with SQL Alchemy, while trying to create a database, i get:

\"sqlalchemy.exc.NoReferencedTableError: Foreign key associated with column \'estate         


        
相关标签:
3条回答
  • 2021-02-03 21:20

    In case of Declarative, I solved this problem by simply importing the class that was 'could not be found'.

    0 讨论(0)
  • 2021-02-03 21:21

    By adding the following line to my parent table solved my problem. In case of Declarative:

    children = relationship("Child")
    

    Otherwise: SQLAlchemy - Classic Mapper

    Also try to have a look in here (SO) too, might help.

    0 讨论(0)
  • 2021-02-03 21:22

    The solution is to replace the strings with actual columns:

    Column('person_id', Integer, ForeignKey(tbl_person.c.id), primary_key=True)
    
    0 讨论(0)
提交回复
热议问题