DatabaseManagementSystems/Practical/Assignment-A9+B4+C1 (Mini Project)/mongo_Connectivity-1.txt

24 lines
409 B
Plaintext
Raw Permalink Normal View History

2024-10-21 23:14:03 +05:30
sudo python3 -m pip install pymongo
###Open mongo
use test1
db.createCollection("emp")
###Open Python
from pymongo import MongoClient
client=MongoClient("mongodb://127.0.0.1:27017")
database=client.test1
collection=database.emp
collection.insert_one({"name":"smartphone","quantity":"10","price":"50000"})
print("inserted")
client.close()
## check output in mongo
Dr.S.K.Wagh (MES's Wadia COE,Pune)