[英]sqlalchemy.exc.NoReferencedTableError: Foreign key could not find table
[英]sqlalchemy.exc.NoReferencedTableError: Foreign key associated with column X could not find table Y with which to generate a foreign key
我在我的 sqlalchemy 模式中收到以下錯誤
python manage.py db migrate
...
sqlalchemy.exc.NoReferencedTableError: Foreign key associated with column
'ArxivPaperFigure.arxiv_id' could not find table 'papers' with which to
generate a foreign key to target column 'arxiv_id'
好的,我能夠通過顯式命名 Papers 表來解決它
__tablename__ = 'papers'
不知道為什么這突然是必要的,因為它以前都有效,但是有了這個修復,一切正常。
對於其他人的參考,如果您使用的是模式(例如 Postgres),您可能還必須指定它:
# Assumes tables live in schema `my_schema`
arxiv_id = db.Column(db.String(1000), db.ForeignKey('my_schema.papers.arxiv_id'))
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.