EPUB'MongoDB is no SQL database', tags: ['mongodb', 'database', 'NoSQL'], viewers: 104 } ‘_id’ is the special key which get automatically added if the programmer forgets to add explicitly. _id is the 12 bytes hexadecimal number which assures the uniqueness of every inserted document. Insert the data inside a collection : Methods used: insert_one() or insert_many() We normally use insert_one() method document into our collections. Say, we wish to enter the data named as record into the ’myTable’ of ‘mydatabase’. rec = myTable.insert_one(record) The whole code looks likes this when needs to be implemented. # importing module from pymongo import MongoClient # creation of MongoClient client=MongoClient() # Connect with the portnumber and host client = MongoClient(“mongodb://localhost:27017/”) # Access database mydatabase = client[‘name_of_the_database’] # Access collection of the database mycollection=mydatabase[‘myTable’] # dictionary to be added in the database rec={ title: 'MongoDB and Python', description: 'MongoDB is no SQL database', tags: ['mongodb', 'database', 'NoSQL'], viewers: 104 } # inserting the data in the database rec = mydatabase.myTable.insert(record) Querying in MongoDB : There are certain query functions which are used to filter the data in the database. The two most commonly used functions are: find() find() is used to get more than one single document as a result of query. for i in mydatabase.myTable.find({title: 'MongoDB and Python'}) print(i) This will output
Rate this eBook
| File Name: | 6e6751f32f07ee9eddb814d2fe09e772.epub |
| Original Title: | MongoDB with Python for Beginners: complete guide to dealing with Data using MongoDB and Learn Python Programming. |
| Creator / Author: | Leire Verdugo |
| Language: | English (en) |
| Identifier: | ASIN:458040 |
| Publisher: | Leire Verdugo Publishing |
| Category: | Computer Science & Programming |
| Format: | 📗 EPUB eBook |
| File Size: | 3.5 MB |
-2.jpeg)

-12.jpeg)

-1.jpeg)