forked from kingname/SourceCodeofMongoRedis
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchapter_3.py
More file actions
24 lines (19 loc) · 747 Bytes
/
Copy pathchapter_3.py
File metadata and controls
24 lines (19 loc) · 747 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from pymongo import MongoClient
client = MongoClient()
database= client.chapter_3
collection = database.example_data_1
# rows = collection.find({'age': {'$lt': 25, '$gt': 21},
# 'name': {'$ne': '夏侯小七'}})
# for row in rows:
# print(row)
# result = collection.update_many(
# {'name': '公孙小八'},
# {'$set': {'address': '美国', 'age': 80}}
# )
# result = collection.update_one({'name': '隐身人'},
# {'$set': {'name': '隐身人',
# 'age': 0,
# 'address': '里世界'}},
# upsert=True)
# result = collection.delete_many({'age': 0})
# print(result)