python - 在 Django 3 项目中使用 Motor 或任何其他异步 MongoDB 驱动程序
问题描述
有没有办法在 Django 3 项目中使用Motor或任何其他异步 MongoDB 驱动程序?
我尝试使用汽车客户 First:motor_asyncio.AsyncIOMotorClient
和 Second: motor_tornado.MotorClient
。
第一个引发以下异常:
Task <Task pending coro=<SessionMiddlewareInstance.__call__() running at SOMEWHERE>> got Future <Future pending cb=[run_on_executor.<locals>._call_check_cancel() at SOMEWHERE]> attached to a different loop
第二个没有引发任何异常,但它停在我使用insert_one
方法在 db 中插入消息的那一行。
有什么方法可以从 MongoDB 异步插入和读取数据?
编辑:必须有一种motor_asyncio
在 Django 中使用客户端的方法。有谁知道如何做到这一点?
解决方案
推荐阅读
- css - Safari textarea字体渐变动画bug
- swiftui - 视图自动跳转到多行文本字段
- reactjs - Docker - 提供的反应应用程序,资产清单.json 文件名不正确
- r - 如何使用 knitr 为同一块中的绘图设置不同的大小?
- python - 如何将 pip 命令的结果存储到 Pandas Datafarme
- linux - 用于返回小时和分钟用户的 Bash 脚本已被记录
- javascript - 如何计算两张像附件这样的黑白图片的相似度
- apache-nifi - 尼菲|| 结合来自多个 Putsql 处理器的流文件并与其他进程组连接
- javascript - 用 2 个参数模拟下一个函数?
- excel - 如何使用 PhpSpreadsheet 评估 CSE 公式?