Skip to main content
Filter by
Sorted by
Tagged with
3 votes
1 answer
181 views

We're using Tornado-based services, which fork and then create DB connections. This was all working fine until we tried upgrading to python 3.11 (from 3.8) and using pymongo 4.8.0. Now, we very ...
kbosak's user avatar
  • 1,947
0 votes
0 answers
60 views

I updated my backend deployment (Flask app) with a new feature not related to database logic, and suddenly MongoDB Atlas connections no longer work. Before the update, everything was fine. Local ...
SOEUNG Phearaneron's user avatar
0 votes
0 answers
61 views

I have data which pymongo fails to upload, and, I cannot understand why. Data available here main2.py: from pymongo import MongoClient import json client = MongoClient(host='localhost') db = client....
deostroll's user avatar
  • 12k
1 vote
0 answers
91 views

I'm building an authorization/access control system in a Python application that uses PyMongo to access MongoDB. I need to dynamically decide—at runtime and for arbitrary query shapes—whether a given ...
GuyEternal's user avatar
1 vote
1 answer
94 views

The docs say that each mongo client maintains a connection pool, the max size of which I can specify. Is there anyway to check the number of open connections made by a specific mongo client at a given ...
Sandil Ranasinghe's user avatar
1 vote
1 answer
264 views

I'm trying to migrate from motor to pymongo's AsyncMongoClient. After doing some upgrading/installing on pymongo I am having the below error when running this import from beanie import Document ...
Masterstack8080's user avatar
0 votes
0 answers
46 views

Let's say I have a command: my_collection.update_one({...}, { "$set": { "title": "Title 1" } }) How to make it adding update_at field with current date when update ...
Alex Burla's user avatar
1 vote
3 answers
95 views

I'm experiencing a consistency issue with MongoDB in production. I have a 3-node replica set deployed on OVH, and sometimes count_documents() and find() return different results for the exact same ...
Ryad's user avatar
  • 21
0 votes
0 answers
73 views

We're using Python (3.12) with Pydantic models to represent schemas for our MongoDB collections, which we then instantiate with SomeModel.model_validate(<results of pymongo query>). We define ...
Gloomy's user avatar
  • 1,529
0 votes
1 answer
47 views

i have a mongodb with documents containing a list of "pages", as sub-documents, like { pages: [ { a:1, b: "foo"}, { a:2, b: "bar"}, ] } now i want to update the ...
A. Rabus's user avatar
  • 537
0 votes
1 answer
96 views

I'm very new to MongoDB and I'm trying to get the killAllSessions or one of its variants to work, in mongosh and/or using pymongo. I have a simple, standalone instance of mongod running in a Docker ...
Rodney Lott's user avatar
0 votes
1 answer
94 views

I have a MongoDB collection that contains several fields with dots, like: { "symbol.name": "Some name" "symbol.state": "Some state" // etc. } Now, ...
Nikolay Kovalenko's user avatar
0 votes
1 answer
48 views

per the official PyMongo's documentions for maxIdleTimeMS maxIdleTimeMS (optional): The maximum number of milliseconds that a connection can remain idle in the pool before being removed and ...
Srikar's user avatar
  • 14
1 vote
1 answer
55 views

I have a MongoDB document like: [ { _id: ObjectId('67cfd69ba3e561d35ee57f51'), created_at: ISODate('2025-03-11T06:22:19.044Z'), conversation: [ { id: '...
NPatel's user avatar
  • 21.4k
0 votes
1 answer
60 views

I am creating a tracker that tracks the usage of invites on discord and who used which invite when a member joins. I am storing the data in mongodb. I am having trouble update the uses value which I ...
user29836029's user avatar
1 vote
0 answers
98 views

My company runs a Flask API connected to MongoDB on atlas. Currently, we have minimal logging and metrics and rely solely on Altas to monitor DB usage. This month we realized the DB is being queried ...
Lance's user avatar
  • 123
0 votes
0 answers
35 views

I'm doing a project for school that uses an .ipynb file to create a dashboard and connect to a MongoDB collection to output a table and map. The code is here: # Setup the Jupyter version of Dash from ...
Joseph Caron's user avatar
2 votes
1 answer
385 views

I'm testing a function that performs a bulk upsert using UpdateOne with bulk_write. In production (using the real MongoDB client) everything works fine, but when running tests with mongomock I get ...
Alon Barad's user avatar
  • 2,103
0 votes
0 answers
54 views

I am trying to maintain a consistent datatype for my datetimes in a Mongo collection, where some come from PyMongo, and others come from flask-mongoengine. In Flask, the relevant model entry is: ...
James_SO's user avatar
  • 1,387
0 votes
1 answer
48 views

I need to download multiple files at once from MongoDB, and then process the result as soon as file is downloaded. But the thing is, it's not faster of sync cycle. It seems like it still waits for ...
Nar Jovan's user avatar
  • 284
0 votes
0 answers
127 views

I have AsyncIOMotorClient code as below. def get_client(): """ Get Client. Get the client for the database connection. """ return motor.motor_asyncio....
NPatel's user avatar
  • 21.4k
1 vote
1 answer
626 views

It seems that a pymongo 4.10 async client does not raise an exception when there is a problem with the connection. Taken from the doc, a test without any mongo DB running locally yields: >>> ...
Plup's user avatar
  • 1,362
0 votes
0 answers
36 views

One of the columns in a oracle table has Integer values which needs to be stored in mongodb as Long. Currently this column has values less than int32 can store. But as a futureproofing we want it to ...
LSB's user avatar
  • 1
1 vote
2 answers
231 views

I have a big application in Python 3.11, but I've narrowed the problem into a smaller example to demonstrate, and I get the same error. Assuming I have a class called Product which is a Document: # /...
user28717641's user avatar
0 votes
0 answers
49 views

I have mongodb base structure [{"_Id": 12345678910, "offer_id": [1,2,3,4], "barcodes": [200, 300, 400, 500], "groups":[]"}, {"_Id": 12345678911, &...
Uniqpr0's user avatar
  • 11
0 votes
1 answer
39 views

I am using pymongo in multiprocessing. I use 6 processes to calculate something and insert the calculation result into MongoDB. import multiprocessing import sys import pymongo import datetime from ...
SerSmile's user avatar
0 votes
0 answers
53 views

my code here: import os import bson from bson.codec_options import CodecOptions bson_codec_options = CodecOptions( datetime_conversion='DATETIME_AUTO', tz_aware=True, ...
Griffith's user avatar
1 vote
0 answers
219 views

I am using FastAPI + pymongo (sync routes) and saw motor was recommended for 'best practices' on FastAPI. I set up two routes with the same DB call, one using async router + motor, one using sync + ...
serp002's user avatar
  • 137
0 votes
2 answers
306 views

I created an Azure Cosmos (RU) Serverless database (sharded) with a MongoDB engine and would like to use Python and pymongo to run queries on it. I am not managing to connect to it in any way. I have ...
ilVacca's user avatar
  • 113
0 votes
2 answers
61 views

I need to fetch documents given a list of tags, but I am having trouble finding the right syntax. For example, I have this collection: { "name": "Mike", "roll_no"...
Sim81's user avatar
  • 1,974
0 votes
1 answer
121 views

I have the following python 3.12.4 code that inserts a JSON in a mongoDB deployed locally through a docker container using dockerhub' image "mongo:4.4.7" myClient = pymongo.MongoClient(&...
user27918202's user avatar
2 votes
1 answer
57 views

I have post documents like this : post = { "_id": "uid1", "userID": "user1", "likeNum": 30, } My current pipeline looks like this with user_ids ...
Tom3652's user avatar
  • 2,975
0 votes
1 answer
49 views

I'm writing a REST API using Flask and MongoDB (I use pymongo to interact with the database). I'm having an issue that seems to be related to race conditions. I have been able to reproduce my use case ...
Rodrigo Morales's user avatar
1 vote
0 answers
44 views

I am trying to do the following operation concurrently across many machine operation = {"$push": {field_name: task}} result = table.find_one_and_update({'_id': _id}, operation, ...
Srinjoy Choudhury's user avatar
0 votes
1 answer
100 views

I'm working on a project using Django version 3.0.8 and PyMongo version 3.11.3. Currently, for each incoming request, a new MongoClient is created, and the connection is destroyed once the request is ...
RJ J's user avatar
  • 25
0 votes
0 answers
86 views

The task is to set up a MongoDB replica set from a single node and connect to it from another container using pymongo. After running docker compose up -d, the behavior is as follows: The connection to ...
Spotika4's user avatar
1 vote
1 answer
441 views

I'm working on a Python app that uses MongoDB (with pymongo for connection) and need to avoid race conditions when adding documents to a collection. Unfortunately, I can't use transactions because I ...
Tikrong's user avatar
  • 61
0 votes
0 answers
780 views

When I'm trying to connect to pymongo getting below error pymongo.errors.ConfigurationError: The resolution lifetime expired after 21.215 seconds: Server 192.168.1.1 UDP port 53 answered The DNS ...
Mahesh's user avatar
  • 33
0 votes
1 answer
454 views

I have a peice of python code which is using the PyMongo library to insert into my mongodb Collection hosted on MongoDB Atlas. Im trying to insert the following doc into a collection called Customer ...
GabT's user avatar
  • 35
1 vote
1 answer
69 views

I want to add database functionalities to my Flask app hosted on Vercel. When using pymongo the website throws HTTP 500 saying that my app crashed. It also says that I should check the logs. The logs ...
Isus Ramzy's user avatar
2 votes
2 answers
99 views

I have 2 collections users and files. A user document looks like this : { "_id": "user1", "name": "John" } A file document looks like this : { "_id&...
Tom3652's user avatar
  • 2,975
1 vote
1 answer
66 views

Ok, I have a MongoDB database, using a Python module to perform CRUD functions, and passing the resulting info into a Dash app. Here is the relevant Python method: def read(self, query): ...
Chelaine Echols's user avatar
0 votes
1 answer
110 views

I'm using Mongo db from Python. Creating collections using this code: self.client = MongoClient(MONGODB_CONNECT) self.db = self.client[MONGODB_NAME] self.db.create_collection(collection_name, options) ...
Guian's user avatar
  • 4,836
0 votes
1 answer
313 views

I want to connect to a MongoDb database using PySaprk. I have downloaded mongo-spark-connector_2.12-10.1.0-all.jar and copied it to the Spark jars directory. This is my code. from pyspark.sql import ...
Rirro Romeu's user avatar
0 votes
1 answer
59 views

The default Dataframe.to_json() exports like this: { "date": { "0": Example_date1, "1": Example_date2 } "name": { "0&...
mrlelis's user avatar
0 votes
1 answer
220 views

I'm trying to use PyMongo in a type safe(ish) way in VS Code. I've tried following the type hints section in the PyMongo documentation and arrived at the following (app is a Flask instance): from ...
naivedeveloper's user avatar
1 vote
1 answer
44 views

Here's what my records look like: I have obtained this by using collection.find().limit(1) [ { "_id": {"$oid": "..."}, "husband.firstName": "John&...
mateusz_mp's user avatar
0 votes
1 answer
50 views

An error is output when connecting from ECS Fargate to Mongodb Atlas. error occured: SSL handshake failed: ac-xvafg1z-shard-00-00.pizmgb2.mongodb.net:27017: [SSL: TLSV1_ALERT_INTERNAL_ERROR] tlsv1 ...
tthogho1's user avatar
0 votes
0 answers
68 views

My collection with fields: [ { "_id": xxx, "field": { "subfield": [ { "k1": "a", "k2": "b&...
OJT's user avatar
  • 909
1 vote
1 answer
44 views

I need to take a field from a document as input, like below: "participants": ["John", "Peter"], and make the output field like that: "participants": [ { ...
user avatar

1
2 3 4 5
138