Flask + MongoDB Tutorial

In this tutorial, I’ll demonstrate how can you use Flask together with MongoDB.

Structure

We’ll use the following structure for our project

app/
__init__.py # Flask app
database.py # Main database class
models/
job.py # Job DB model
main/
__init__.py
routes.py # Main page routes
templates
main.html # Main page HTML template
requirements.txt # Requirements for running the application
Continue reading “Flask + MongoDB Tutorial”

Mongo Shell By Example

Start the mongo shell

Start the mongo shell by running mongo

Note: this will connect using the default port 27017. Use -p for specifying a different port.

You should get an output similar to the following

MongoDB shell version v4.0.3
connecting to: mongodb://127.0.0.1:27017
Implicit session: session { "id" : UUID("2323-8as8-23aa-8fsa") }
MongoDB server version: 4.0.3
>

From this moment on, everything you’ll type will be executed in the mongo shell.

Continue reading “Mongo Shell By Example”