- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathm.py
More file actions
Latest commit
15 lines (13 loc) · 351 Bytes
/
Copy pathm.py
File metadata and controls
15 lines (13 loc) · 351 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
frompymongoimportMongoClient
defget_db():
client=MongoClient('localhost:27017');
db=client.myFirstPythomMB;
returndb;
defadd_country(db):
db.countries.insert({"name" : "Canada"})
defget_country(db):
returndb.countries.find_one()
if__name__=="__main__":
db=get_db();
add_country(db)
printget_country(db)