How to setup MongoDB with Jupyter Notebook

First step, Install python 3.9.1 for use on python and write the code below

import pymongo
from pymongo import MongoClient

username=’myUserAdmin’
password=’abc123′
client = MongoClient(‘mongodb://%s:%s@127.0.0.1’ % (username, password))
db=client[‘…


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Suttipong Kullawattana

First step, Install python 3.9.1 for use on python and write the code below

import pymongo
from pymongo import MongoClient

username='myUserAdmin'
password='abc123'
client = MongoClient('mongodb://%s:%s@127.0.0.1' % (username, password))
db=client['mongotestdb']

my_collection = db["patient_data"]

patient_record = {
   "Name": "Maureen Skinner",
   "Age": 87,
   "Sex": "F",
   "Blood pressure": [{"sys": 156}, {"dia": 82}],
   "Heart rate": 82
}

my_collection.insert_one(patient_record)

for item in my_collection.find():
    print(item)

Second step, Install homebrew with $ /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

Third step, Install Jupyter Notebook on Windows, MacOS or Linux and try to install $ pip install notebook in terminal and run $ jupyter notebook

Fourth step, Install MongoDB Community Edition on macOS mongoDB

install $ brew tap mongodb/brew

Image description

Five step, Install mongosh for start mongosh, and create role user on database

Image description

Result on MongoDB Compass

Image description

Reference : start connecting mongoDB with Jupyter Notebook, MongoDB Community,
Getting started with mongodb pyspark and jupyter-notebook


This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Suttipong Kullawattana


Print Share Comment Cite Upload Translate Updates
APA

Suttipong Kullawattana | Sciencx (2022-10-15T13:11:29+00:00) How to setup MongoDB with Jupyter Notebook. Retrieved from https://www.scien.cx/2022/10/15/how-to-setup-mongodb-with-jupyter-notebook/

MLA
" » How to setup MongoDB with Jupyter Notebook." Suttipong Kullawattana | Sciencx - Saturday October 15, 2022, https://www.scien.cx/2022/10/15/how-to-setup-mongodb-with-jupyter-notebook/
HARVARD
Suttipong Kullawattana | Sciencx Saturday October 15, 2022 » How to setup MongoDB with Jupyter Notebook., viewed ,<https://www.scien.cx/2022/10/15/how-to-setup-mongodb-with-jupyter-notebook/>
VANCOUVER
Suttipong Kullawattana | Sciencx - » How to setup MongoDB with Jupyter Notebook. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2022/10/15/how-to-setup-mongodb-with-jupyter-notebook/
CHICAGO
" » How to setup MongoDB with Jupyter Notebook." Suttipong Kullawattana | Sciencx - Accessed . https://www.scien.cx/2022/10/15/how-to-setup-mongodb-with-jupyter-notebook/
IEEE
" » How to setup MongoDB with Jupyter Notebook." Suttipong Kullawattana | Sciencx [Online]. Available: https://www.scien.cx/2022/10/15/how-to-setup-mongodb-with-jupyter-notebook/. [Accessed: ]
rf:citation
» How to setup MongoDB with Jupyter Notebook | Suttipong Kullawattana | Sciencx | https://www.scien.cx/2022/10/15/how-to-setup-mongodb-with-jupyter-notebook/ |

Please log in to upload a file.




There are no updates yet.
Click the Upload button above to add an update.

You must be logged in to translate posts. Please log in or register.