Questions tagged [motorengine]

Motorengine is an ODM product built on Python Motor. It strives to be 100% compatible with [MongoEngine][1] as far as the data in mongoDB goes.

Motorengine is an ODM product built on Python Motor. It strives to be 100% compatible with MongoEngine as far as the data in mongoDB goes.

Read more at motorengine.readthedocs.io

Also see the project on GitHub

32 questions
18
votes
3 answers

MongoDb with FastAPI

I am playing around with FastAPI a bit and wanted to connect it to a MongoDB database. I however am confused which ODM to choose between motor which is async and mongoengine. Also, in the NoSQL example here they have created a new bucket and also…
Ayush Singh
  • 1,409
  • 3
  • 19
  • 31
14
votes
3 answers

Future task attached to a different loop

I am trying to connect to mongodb in FastAPI. I am repeatedly getting this exception. File - main.py app = FastAPI( title=config.PROJECT_NAME, docs_url="/api/docs", openapi_url="/api" ) @app.get("/api/testing") async def testit(): …
5
votes
1 answer

How to get count on MongoDB's Motor driver?

I want to get count with Motor's diver but I got this error. AttributeError: 'AsyncIOMotorCursor' object has no attribute 'count' This is my code: await MOTOR_CURSOR.users.find().count()
Ali Hallaji
  • 3,712
  • 2
  • 29
  • 36
3
votes
1 answer

Python 3.6 - Sanic Motorengine

I am trying to setup the new Sanic web framework (which is promised to be extremely fast) with motorengine in order to achieve 100% async. My setup so far: app = Sanic(__name__) @app.listener('after_server_start') async def setup_dbconn(app,…
Creative crypter
  • 1,348
  • 6
  • 30
  • 67
2
votes
1 answer

abstract method async and sync implementation in Python

Let's say I have BaseClass which contains some logic in main_function() which is common for both SyncClass and AsyncClass. Let's say those 2 classes have their unique implementation of get_data() and the former gets in synchronous manner, while the…
giliev
  • 2,938
  • 4
  • 27
  • 47
1
vote
0 answers

async/await seems to be blocking requests in FastAPI

I haave a challenge with async/await blocking other requests in FastAPI. My code used to work well calling requests in def functions. For instance: someRequestsApis = APIRouter() someRequestsApis.get("/something/") def getThings(): return…
DUMBA
  • 159
  • 2
  • 10
1
vote
1 answer

AsyncIOMotorClient does not connect to local mongodb

I am trying to move my web blog-like app from Flask to Quart which aparently could significantly improve the performance. However, I am not able to replicate flask_mongoengine behaviour. So far I tried AsyncIOMotorClient and quart-motor. If I…
Anatoly Bugakov
  • 772
  • 1
  • 7
  • 18
1
vote
1 answer

Control motor brushless with esc using jetson nano

I have done a lot of research on how to control a brushless motor with an ESC (Electronic Speed Controller) using a nano jetson. I did not find how to connect the esc to the gpio of the jetson. I also did not find how to make a simple code to…
1
vote
1 answer

What is the correct MongoDB query to find all documents containing one or more item in an (unordered) list?

I am working on an API using FastAPI that interacts with a Mongo DB via Motor. Our database contains documents on various illnesses such that look like this: { "_id": { "$oid": "6008b21ba1285a480088ff48" }, "names":…
Moritz
  • 11
  • 1
1
vote
1 answer

Python futures : How do I get the json from a future object in Tornado?

This is a post handler : handler.py from imports import logic @gen.coroutine def post(self): data = self.request.body.decode('utf-8') params = json.loads(data) model_id= params['model_id'] logic.begin(model_id) The logic object is…
vivekanon
  • 1,813
  • 3
  • 22
  • 44
0
votes
0 answers

Htting the POST route trying to insert a new document in the database gives me an error. (FastAPI)

So, I am trying to build a simple TODO app using FastApi and MongoDB. All the routes work fine, except for the POST route. When I try to post a "title" and and "description" using the SwaggerUI, it gives me an error. Surprsingly, if I modify the…
Eeshaan
  • 21
  • 4
0
votes
0 answers

FastAPI: Error with storing db connection in app.state

Recently I am facing the error AttributeError: 'State' object has no attribute 'db' and unable to store the DB connection in app.state.db and use it in different routes. db.py from motor.motor_asyncio import AsyncIOMotorClient from decouple import…
0
votes
0 answers

Problem upgrading pymongo from version 4.2 to 4.4

I have an application that uses Mongo 4.2, working correctly. I'm upgrading it to Mongo 4.4 (my only change has been that I've changed that version in my docker-compose) and I'm getting now the following error ERROR - ChangeStream(DtaSystem) failure…
Carabes
  • 532
  • 2
  • 4
  • 16
0
votes
1 answer

pymongo.errors.OperationFailure: Each element of the 'pipeline' array must be an object

my query db.sections.aggregate([ { "$lookup": { "from": "faqs", "localField": "_id", "foreignField": "section_id",  "as": "faq","pipeline": [{ $project: { _id: 1, question: 1,answer:1 } }] } }]); response [ { _id: '63e4a4d9304637ec1b578136', …
putta
  • 35
  • 8
0
votes
0 answers

How to reference two different collections of same db based on object_id in mongo and fastapi

my schema for two collections. class SectionModel(BaseModel): id: PyObjectId = Field(default_factory=PyObjectId, alias="_id") name: str = Field(max_length=50) class Config: allow_population_by_field_name = True …
putta
  • 35
  • 8
1
2 3