-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdboperations.py
42 lines (30 loc) · 903 Bytes
/
dboperations.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
import json
# Update user status
def UserStatus(user, status):
# Open the file to read
with open('users.json', 'r') as file:
# Load the JSON data
data = json.load(file)
# Iterate through the list of dictionaries
for item in data:
# Check if the dictionary has the key 'admin'
if user in item:
if not status:
item[user]['confirm'] = False
else:
item[user]['confirm'] = True
# Convert the updated data back to a JSON string
newData = json.dumps(data, indent=4)
# Open the file to write
with open('users.json', 'w') as file:
# Write the updated JSON data to the file
file.write(newData)
# Add user data
def UserBuild(user, data):
pass
# Update user data
def UserUpdate(user, key, value):
pass
# Get user data
def UserData(user):
pass