MongoDB is a cross-platform document-oriented database. Classified as a NoSQL database. MongoDB can be used for rapid development and storing of Big Data while the database is very scalable.
Installation on macOS
1 | brew cask install mongodb |
Start MondoDB by launching the MongoDB.app icon in your Applications.
Development
Install python3 MongoDB module to beginn to interact with the databse
1 | pip3 install pymongo |
1 2 3 4 5 6 7 | import pymongo from pymongo import MongoClient client = MongoClient('localhost', 27017) db = client.mydb users = db.users user1 = {"username": "nick", "password": "mypassword", "favorite_number": 445, "hobbies": ["python", "pizza"]} |
1 2 | test_users = [{"username": "ann", "password": "12345"}, {"username": "jane", "password": "blue"}] bulk_insert = users.insert_many(test_users) |
users.find().count() |
users.find({"favorite_number": 445}).count() |
Leave a Reply