首页 > 解决方案 > 在 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 中使用客户端的方法。有谁知道如何做到这一点?

标签: pythondjangomongodbasynchronous

解决方案


推荐阅读