相关文章推荐
小眼睛的热带鱼  ·  Python equivalent of ...·  3 月前    · 
俊逸的火锅  ·  Python 控制台 — Blender ...·  3 月前    · 
健身的抽屉  ·  在 Google Cloud 上使用 ...·  3 月前    · 
直爽的黑框眼镜  ·  Difference between ...·  3 月前    · 
性感的毛豆  ·  通过SWIG实现在Python中调用C++代 ...·  3 月前    · 
瘦瘦的山羊  ·  Re: Passing (by ...·  1 年前    · 
才高八斗的冰棍  ·  R语言实现相空间重构的参数选取_ami方法找 ...·  1 年前    · 
慈祥的紫菜汤  ·  How to install the ...·  2 年前    · 
曾经爱过的小笼包  ·  《鬓边不是海棠红》:走向“主流”的耽改剧_文 ...·  2 年前    · 
飞奔的苦咖啡  ·  马朝旭接任外交部发言人 ...·  2 年前    · 
Code  ›  Python开发 常见异常和解决办法开发者社区
python
https://cloud.tencent.com/developer/article/1694550
玩滑板的凉面
3 年前
作者头像
cutercorley
0 篇文章

Python开发 常见异常和解决办法

前往专栏
腾讯云
开发者社区
文档 意见反馈 控制台
首页
学习
活动
专区
工具
TVP
文章/答案/技术大牛
发布
首页
学习
活动
专区
工具
TVP
返回腾讯云官网
社区首页 > 专栏 > Corley的开发笔记 > Python开发 常见异常和解决办法

Python开发 常见异常和解决办法

作者头像
cutercorley
发布 于 2020-09-08 21:03:44
1.1K 0
发布 于 2020-09-08 21:03:44
举报

1.sqlalchemy创建外键关系报错property of that name exists on mapper

SQLAlchemy是Python编程语言下的一款开源软件,提供了SQL工具包及对象关系映射(ORM)工具,使得在Python中操作MySQL更加简单。在给两个表创建外键关系时可能会报错:

sqlalchemy.exc.ArgumentError: Error creating backref 'xxx' on relationship 'xxx.xxx': property of that name exists on mapper 'mapped class xxx->xxx'

两个数据模型如下:

class Website(Base):
    __tablename__ = 'website'
    id = Column(Integer, primary_key=True, autoincrement=True)
    name = Column(String(10), nullable=False)
    link = Column(String(40), nullable=False)
    orders = relationship('Order', backref='website')
class Order(Base):
    __tablename__ = 'order'
    id = Column(String(50), primary_key=True)
    desc = Column(Text, nullable=False)
    link = Column(String(80), nullable=False)
    contact = Column(String(30))
    category = Column(String(15))
    is_valid = Column(Boolean, nullable=False)
    add_time = Column(DateTime, default=datetime.now)
    website = Column(Integer, ForeignKey('website.id'), nullable=False)
 
推荐文章
小眼睛的热带鱼  ·  Python equivalent of PHP's file_get_contents on websites (NOT LOCAL FILES) · GitHub
3 月前
俊逸的火锅  ·  Python 控制台 — Blender Manual
3 月前
健身的抽屉  ·  在 Google Cloud 上使用 Machine Learning API:实验室挑战赛 | Google Skills
3 月前
直爽的黑框眼镜  ·  Difference between Auto_now_add and Auto_now in Django - GeeksforGeeks
3 月前
性感的毛豆  ·  通过SWIG实现在Python中调用C++代码 – My Home
3 月前
瘦瘦的山羊  ·  Re: Passing (by reference) a Python string to Fortran function (subroutine) - Intel Community
1 年前
才高八斗的冰棍  ·  R语言实现相空间重构的参数选取_ami方法找时间延迟-CSDN博客
1 年前
慈祥的紫菜汤  ·  How to install the Azure CLI | Microsoft Learn
2 年前
曾经爱过的小笼包  ·  《鬓边不是海棠红》:走向“主流”的耽改剧_文化课_澎湃新闻-The Paper
2 年前
飞奔的苦咖啡  ·  马朝旭接任外交部发言人 20年前因雄辩闻名(图)-搜狐新闻
2 年前
今天看啥   ·   Py中国   ·   codingpro   ·   小百科   ·   link之家   ·   卧龙AI搜索
删除内容请联系邮箱 2879853325@qq.com
Code - 代码工具平台
© 2024 ~ 沪ICP备11025650号