-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathchanger.py
38 lines (31 loc) · 1.23 KB
/
changer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from pymongo import MongoClient
# client = MongoClient('mongodb+srv://admin:password1234$@web-map.qzzvr.mongodb.net/myFirstDatabase?retryWrites=true&w=majority')
client = MongoClient("mongodb://localhost:27017/")
db = client["web-map"]
db.domains.create_index("url", unique=True)
def changes(lst):
db.domains.update_one({"url": lst[0]}, {"$set": {"count": lst[1]}}, upsert=True)
# if lst:
# if lst[2] == "new":
# try:
# db["domains"].insert_one({
# "url": lst[0],
# "count": 1
# })
# # print("n" + "\r")
# # if db["domains"].count_documents({"url" : lst[0]}) == 0:
# # else:
# # print("r" + "\r")
# except Exception as e:
# db["domains"].update_one({"url" : lst[0]}, {"$set":{"count":lst[1]}})
# # print('x',)
# else:
# try:
# db["domains"].update_one({"url" : lst[0]}, {"$set":{"count":lst[1]}})
# # print("u" + "\r")
# # print('y')
# except Exception as e:
# # print(e)
# pass
# else:
# pass