Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

198
Views
How can I use MongoDB with Flask?

Okay so I have Flask installed and I am wondering how I can connect and use a MongoDB database with a Flask app that I am starting to build soon.

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

You can use any of these three libraries

  • Flask-PyMongo - https://flask-pymongo.readthedocs.io/en/latest/
  • Flask-MongoAlchemy - https://pythonhosted.org/Flask-MongoAlchemy/
  • Flask-MongoEngine - http://docs.mongoengine.org/projects/flask-mongoengine/en/latest/

I personally use flask mongoengine and every things work fine

over 4 years ago · Santiago Trujillo Report

0

I personally find the PyMongo library simple and easy to use.

You first need to import MongoClient and create a connection:

from pymongo import MongoClient
client = MongoClient()

Then get your db instance and collection (table):

db = client.my_database
collection = db.my_collection

You can then manipulate your data by working with JSON documents that hold your data. There is a complete example on their website.

Take a look at this tutorial on how to use PyMongo.

over 4 years ago · Santiago Trujillo Report

0

Maybe you don't have to use special libraries for Flask to connect to MongoDB.

Just treat Flask application as a normal Python program, and connect to MongoDB via normal Python libraries like PyMongo.

Here's an example by someone else. A Flask app connecting to MongoDB via PyMongo.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!