-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdatabase.py
48 lines (38 loc) · 965 Bytes
/
database.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
39
40
41
42
43
44
45
46
from pymongo import MongoClient
import traceback
import time
import os
def getGroups():
"""
Get all Cooking Groups from the Database
"""
groups = []
for group in client["groups"].find({},{'_id': False}):
groups.append(group)
return groups
def getProxys():
"""
Get all Proxys from the Database
"""
proxys = {}
for proxy in client["proxys"].find({},{'_id': False}):
proxys[proxy["name"]] = proxy["proxys"]
return proxys
def getSettings():
"""
Get the Settings from the Database
"""
return client["settings"].find_one({},{'_id': False})
def Connect():
"""
Connect Database
"""
global client
try:
client = MongoClient(os.environ['DB'])["monitorsolutions"]
except Exception as e:
print(f"[DATABASE] Exception found: {traceback.format_exc()}")
time.sleep(10)
Connect()
#Connect Database when the Script is imported
Connect()