from pymongo
import MongoClient
client
= MongoClient
('localhost', 27017)
db
= client
.xiaomei
collection
= db
.test
collection
.insert
({"name":'newfroend',"age":25,"addr":'Cleveland'})
collection
.insert
([{"name":'lucy',"age":25,"addr":'Cleveland'},{"name":'pisa',"age":18,"addr":'Idin'}])
collection
.update
({"name":'newfroend'},{"Name":'oldfriend',"age":18})
collection
.delete_one
({"name":'lucy'})
collection
.delete_many
({"name":'lucy'})
print(collection
.find_one
())
for item
in collection
.find
():
print(item
)
collection
.remove
()
collection
.drop
()
转载请注明原文地址: https://mac.8miu.com/read-494384.html