Questions tagged [flask-pymongo]
75 questions
0
votes
1 answer
flask-pymongo: I put mongo in a separate python file, and it became NoneType
I have three files:
params.py like this:
from flask_pymongo import PyMongo
mongo = PyMongo()
server.py like this:
from params import mongo
mongo.init_app(app)
A function regarding a post in a blueprint in views.py like this:
from params import…
0
votes
0 answers
Flask-PyMongo exception on mongo initialisation with init_app()
i am using init_app() to initialize mongo connection but it won't give me any error at connection despite mongo server is not running, but gives error when fetching the data using find.
mongo = PyMongo()
def create_app(config_name):
if…

Amit Verma
- 1
- 1
0
votes
2 answers
AttributeError: 'bytes' object has no attribute 'encode'
I am trying to build a user login system and I have successfully built the user register page, but when I try to login I get the error below. I am using flask, python3.6 and pymongo.
This is the error: AttributeError: 'bytes' object has no…

elvis-chuks
- 86
- 2
- 6
0
votes
1 answer
Find one - insert/update - flask_pymongo
Here is my code:
from flask_pymongo import PyMongo
app.config['MONGO_DBNAME'] = 'TestDB'
app.config["MONGO_URI"] = "mongodb://localhost:27017/TestDB"
mongo = PyMongo(app)
filePathHash = "fhdsfl5324hfd"
score = 25
db_operations =…

LEE
- 3,335
- 8
- 40
- 70
0
votes
2 answers
Connect to Mongo Server from Python Flask Application
I'm a beginner at python. I'm trying to connect to Mongo DB server from my python flask application. But I couldn't able to run the application as I'm facing the below problem.
from flask import Flask, render_template
from flask_pymongo import…

Kishor kumar R
- 195
- 2
- 17
0
votes
1 answer
Why Flask-PyMongo bulk_writes method doesn't exist?
I have some code snippet like this:
from flask import Flask
from flask_pymongo import PyMongo
from pymongo import InsertOne, UpdateOne, DeleteOne, ReplaceOne
from flask import jsonify
app = Flask(__name__)
app.config['MONGO_DBNAME'] = 'MyDB'
mongo…

Geeocode
- 5,705
- 3
- 20
- 34
0
votes
2 answers
install flask-pymongo with pip- python 3.6
hellow everyone,
i tried to install PyMongo package with pip( i hope that is the way to do it). [its a part of a login system]
my command line was:
C:/Python36/Scripts/pip install PyMongo
But, when i put it in the command line i got
the system…
user9678733
0
votes
1 answer
How to assign to a variable the first value of the cursor object in flask pymongo
I am trying to assign to a variable the value of nr from the first value of the Cursor object named items in my code (which is the max of nr) but I don't know how to do that.(I am using flask pymongo. I saw a question similar to mine but it doesn't…

Ax M
- 330
- 3
- 15
0
votes
1 answer
Highest value(max) from mongodb collection error - Flask Python
I am trying to get the highest value for nr from a mongo database collection named prob that looks like this for now:
{
"_id": {
"$oid": "5ae9d062f36d282906c59736"
},
"nr": 1,
"nume": "numeunu",
"enunt": "-",
…

Ax M
- 330
- 3
- 15
0
votes
0 answers
ImportError: No module named 'bson.objectid'
from bson.objectid import ObjectId
,after importing this, I am getting the following error
ImportError: No module named 'bson.objectid'.
This works for me on windows but not on ubuntu ,for the pymongo version 3.5.1

Divyanshu
- 11
- 5
0
votes
1 answer
Can't connect to MongoDB via flask_pymongo
I just encountered a problem while playing with Flask and MongoDB. Here are scenarios
With Authorization Enabled
If I use PyMongo() from flask_pymongo with mongo = PyMongo(app) pattern, I just get Authorization Errors. While I am able to…

Nafees Anwar
- 6,324
- 2
- 23
- 42
0
votes
1 answer
Flask Pymongo Insert
I'm calling db dev to insert data into its collection. But it's creating a new collection and inserting data into admin db.
from app import app
from flask import Flask
from flask import jsonify
from flask import request
from flask_pymongo import…

Anubhav
- 147
- 1
- 13
-1
votes
1 answer
Python Flask Pymongo global db object is returned as None
I am trying to create an API to fetch data from my Atlas MongoDB using Flask. I was following this tutorial https://www.mongodb.com/compatibility/setting-up-flask-with-mongodb
However I get the following Error when trying to get some data from my…

Samat
- 43
- 5
-1
votes
1 answer
store a single variable from mongoDB to a variable in flask
I have a mongoDB with a collection named Movies inside the collection i stored some info like this:
I also have an html and i just want to display the title:
{{ title}}
to do that I run this code: @app.route("/movieInfo") def…
Λευτέρης Φωτεινάτος
- 49
- 1
- 8
-1
votes
1 answer
Strange equality error with PyMongo-flask
So I have this api endpoint:
@app.route("/subject", methods=["GET"])
def GET_subject():
subject = request.args["subject"]
page = int(request.args["page"])
pagesize = 10
subjectResults =…

Michael Brennan
- 632
- 1
- 5
- 15