Reputation: 31
I'm developing a webserver using FastAPI, Beanie and Celery. The asynchronous nature of the ODM is userful when writing routers, however there are places where it is not required. For example, in a celery task I don't need to make asynchronous database calls.
Is there a way to make synchronous queries with Beanie?
I'm forced to wrap my celery task code in an async function and run it with asyncio.
Upvotes: 3
Views: 864
Reputation: 21
Check out bunnet!
It is a completely synchronous ODM developed and maintained by the same author as beanie.
See this excerpt of the beanie documentation:
Beanie - is an asynchronous Python object-document mapper (ODM) for MongoDB. Data models are based on Pydantic. [...] There is a synchronous version of Beanie ODM - Bunnet
Upvotes: 2