Briefly about mongodb


Briefly about mongodb:

import pymongo
#connect_string = localhost

from django.conf import settings
my_client = pymongo.mongoclient(connect_string, 27017)

# First define the database name
dbname = my_clientsample_medicines

# Now get/create the collection name (remember you will only see the database in your mongodb cluster after the collection has been created
collection_name = dbnamemedicinedetails

# let's create two documents
medicine_1 =
    medicine_id: rr000123456,
    common_name : paracetamol
    scientific_name : ,
    available : y
    category: fever

medicine_2=
    medicine_id: rr000342522,
    common_name : metformin
    scientific_name : ,
    available : y
    category : type 2 diabetes

# Insert documents

collection_name.insert_many(medicine_1,medicine_2)
# Check count
count = collection_name.count()
print(count)

# Read the docs
med_details = collection_name.find()
# print in terminal
for r in med_details:
    print(rcommon_name)
# Update one document
update_data = collection_name.update_one(medicine_id:rr000123456, set:common_name:paracetamol 500)

# Delete one document
delete_data = collection_name.delete_one(medicine_id:rr000123456)