Questions tagged [flask-pymongo]

75 questions
1
vote
0 answers

Python MongoDB dynamic query building with multiple conditions

I am building an Open Source Project, Python MongoDB ORM (for Flask especially) using flask_pymongo and I am kind of stuck at building dynamic conditions. Below code is what I have written in corresponding files Model.py from app.database import…
0
votes
0 answers

MongoDB Authentication Error when Connecting from Flask-PyMongo

I'm encountering an authentication error when trying to connect my Flask application to a MongoDB server using Flask-PyMongo. I have verified that the credentials are correct, but I'm still facing this issue. app.config['MONGO_URI'] = ( …
0
votes
0 answers

Why am i getting "modulenotfounderror : No module named 'flask_pymongo'"

With: from flask_pymongo import PyMongo Why am i getting: ModuleNotFoundError : No module named 'flask_pymongo' Why am i getting modulenotfounderror : No module named 'flask_pymongo'? I have installed both flask and flask-pymongo on my system…
0
votes
1 answer

How to send image file from form to mongoDB using flask and pymongo

from flask import Flask, render_template, url_for, request, redirect from pymongo import MongoClient from PIL import Image import io from matplotlib import pyplot as plt app = Flask(__name__) client = MongoClient("localhost", 27017) db =…
0
votes
1 answer

Flask-Pymongo DB is returning as None

I am trying create a webapp with Flask-Pymongo, but it is saying that my database does not exist. This is my __init__.py: import os from flask import Flask from flask_pymongo import PyMongo mongo = PyMongo() def init_app(): app =…
Derithus
  • 21
  • 2
0
votes
1 answer

Specific query in pymongo and displaying the data in flask app

I am working on a project, to query for a particular document in mongodb database in pymongo and showing it on flask app. Here is the Code: from flask import Flask from flask_pymongo import PyMongo import pymongo import json app =…
0
votes
1 answer

MongoDB field must be an array

Currently I have a collection with the following documents: [ { "_id": ObjectId("628e6bd640643f97d6517c75"), "company": "bau", "current_version": 0, "form_name": "don't know", "history": [], "id":…
0
votes
1 answer

how to set particular field in array of object in mongodb aggregation or pipeline query along with conditional update of the other field in document?

{ id:1, projectName:'Project1' start:"17-04-2022", end:"12-05-2020", tasks:[ { taskId:1, taskName:'first task', taskStart:'20-04-2022', taskEnd:'25-04-2022' }, { taskid:2, taskName:'second…
0
votes
0 answers

Retrieving an image - Pymongo - Python - Flask

Im trying to making an simple application that you can upload an image and retrieve it from the system. i did the upload image and its working correctly but when i retrieve the image its returning this error TypeError TypeError: argument of type…
Gustavo
  • 41
  • 6
0
votes
1 answer

Flask-PyMongo DBRef is not working as expected

How can I define ref and how to query a collection with ref populating related fields. I defined a ref when inserting a product document in a product collection, but when querying I am getting info as inserted without populating the category field.…
Valentine Sean
  • 79
  • 3
  • 13
0
votes
1 answer

pymongo - Update a data and access the found value

I am trying to update a value of an array stored in a mongodb collection any_collection: { { "_id": "asdw231231" "values": [ { "item" : "a" }, { "item" : "b" } ], "role": "role_one" }, ...many…
jeansyo
  • 21
  • 4
0
votes
1 answer

PyMongo: how to get all objects that match any of possible filters?

I have a list of "usernames" as an array, and a list of posts in a mongodb collection with an "author" variable. I want to get all objects from the collection whose author is one of the usernames in the array. so if: Collection: { "author":…
0
votes
0 answers

Flask & Flask-PyMongo "UserWarning: MongoClient opened before f
ork."

I am working on a Flask application with a MongoDB database. I am using that database for my core application data as well as for Flask-Dance token storage (https://flask-dance.readthedocs.io/en/latest/storages.html). The code for the custom…
Joenarr Bronarsson
  • 515
  • 2
  • 5
  • 20
0
votes
0 answers

Set expireAfterSeconds time to 10 minutes in Pymongo

db.temp.ensure_index("createdAt",expireAfterSeconds=3*60) timestamp = datetime.utcnow() for i in l: i["createdAt"] = timestamp i['table'] = 1 db.temp.insert_one(i) In the above code, expireAfterSeconds is working only if it specifies as…
Divya
  • 1
  • 1
0
votes
1 answer

Using results from pymongo

I have an api using flask and flask-pymongo Im trying to deal with a login function and using passlib try and check if a password hash matches Im getting a 500 server error when making a call to the endpoint My code is as follows: def login(): …
Graham Morby
  • 123
  • 2
  • 11