Session 16
Session 16
16
MongoDB Get started
MongoDB Insert
MongoDB Get Started
MongoDB stores data in JSON-like documents,
which makes the database very flexible and
scalable.
Can download a free MongoDB database at
https://www.mongodb.com.
Python needs a MongoDB driver to access the
MongoDB database.
C:\Users\Your Name\AppData\Local\Programs\
Python\Python36-32\Scripts>python -m pip install
pymongo
MongoDB MongoDB will create the database if it does
not exist, and make a connection to it.
Create
import pymongo
myclient =
pymongo.MongoClient("mongodb://localhost:27017/"
Database )
mydb = myclient["mydatabase"]
Can check if a database exist by listing
all databases in you system.
Create print(myclient.list_database_names())