Integrating MongoDB with Flask
What Is MongoDB?
MongoDB is an open-source document database built on a horizontal scale-out architecture. Founded in 2007, MongoDB has a worldwide following in the developer community.
Instead of storing data in tables of rows or columns like SQL databases, each row in a MongoDB database is a document described in JSON, a formatting language.
What is Flask?
Flask is a micro web framework written in Python. It is classified as a microframework because it does not require particular tools or libraries. It has no database abstraction layer, form validation, or any other components where pre-existing third-party libraries provide common functions. However, Flask supports extensions that can add application features as if they were implemented in Flask itself. Extensions exist for object-relational mappers, form validation, upload handling, various open authentication technologies, and several common framework-related tools.
Why are ORMs useful?
ORMs provide a high-level abstraction upon a relational database that allows a developer to write Python code instead of SQL to create, read, update and delete data and schemas in their database. Developers can use the programming language they are comfortable with to work with a database instead of writing SQL statements or stored procedures.
Step-1: Install Prerequisite and Create a Server.py
>>First, we will install pymongo in order to integrate python with MongoDB.
#pip install pymogo
#pip install flask
>>This is the flask code for creating a flask app that will create an interface between Python and MongoDB.
>>This code can simply enter the database for students in school and can be used to view the data.