tortoise-orm在fastapi的lifespan中访问数据库表时报for r in self._routers:TypeError: ‘NoneType‘ object is not it

解决:升级tortoise-orm使用github上的待发布版

poetry add 'git+https://github.com/tortoise/tortoise-orm.git'

或直接pip安装https://pip.pypa.io/en/stable/cli/pip_install/#examples

pip install --upgrade 'git+https://github.com/tortoise/tortoise-orm.git'

*注:pip安装时如果报443连接超时,可以用ssh的方式(本地公钥需配置到github里):

pip install --upgrade 'git+ssh://git@github.com/tortoise/tortoise-orm.git'

升级完成后,不再报错了

=====================================

如果还想消除warnning提示,可参照库文档的示例修改代码https://tortoise.github.io/examples/fastapi.html#main-py

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值