文章内容

2020/12/5 18:21:43,作 者: 黄兵

Table 'table_name' is already defined for this MetaData instance. Specify 'extend_existing=True'

最近在SQLAlchemy模型增加新表的时候,出现如下错误:

sqlalchemy.exc.InvalidRequestError: Table 'table_name' is already defined for this MetaData instance.  Specify 'extend_existing=True' to redefine options and columns on an existing Table object.

出现问题的原因:

__tablename__ 出现两次相同名称的时候,会出现此提示,这个时候就需要检查代码表名是否有问题,是否冲突。

解决方案:

检查表名是否有问题。


参考资料:

1、SQLAlchemy inheritance not working


分享到:

发表评论

评论列表