-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEditUser.py
More file actions
151 lines (131 loc) · 4.37 KB
/
Copy pathEditUser.py
File metadata and controls
151 lines (131 loc) · 4.37 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import sqlite3
from AddUser import *
def EditUserName(value):
"""function to edit username,
pass in tuple that contains the
new username and the old username in that order"""
if UsernameValidation(value[0]):
try:
with sqlite3.connect("database.db") as db:
cursor=db.cursor()
sql="update User set UserName=? where UserName=?"
cursor.execute(sql,value)
db.commit()
return True
except:
return False
else:
return False
def EditPassword(value):
"""function to edit username,
pass in tuple that contains the
new password and the username in that order"""
if PasswordValidation(value[0]):
try:
with sqlite3.connect("database.db") as db:
cursor=db.cursor()
sql="update User set Password=? where UserName=?"
cursor.execute(sql,value)
db.commit()
return True
except:
return False
else:
return False
def EditFirstName(value):
"""function to edit username,
pass in tuple that contains the
new first name and the username in that order"""
if FirstNameValidation(value[0]):
try:
with sqlite3.connect("database.db") as db:
cursor=db.cursor()
sql="update User set FirstName=? where UserName=?"
cursor.execute(sql,value)
db.commit()
return True
except:
return False
else:
return False
def EditLastName(value):
"""function to edit username,
pass in tuple that contains the
new last name and the username in that order"""
if LastNameValidation(value[0]):
try:
with sqlite3.connect("database.db") as db:
cursor=db.cursor()
sql="update User set LastName=? where UserName=?"
cursor.execute(sql,value)
db.commit()
return True
except:
return False
else:
return False
def EditEmail(value):
"""function to edit username,
pass in tuple that contains the
new email and the username in that order"""
if EmailValidation(value[0]):
try:
with sqlite3.connect("database.db") as db:
cursor=db.cursor()
sql="update User set Email=? where UserName=?"
cursor.execute(sql,value)
db.commit()
return True
except:
return False
else:
return False
def EditStartFavourite(value):
"""function to edit username,
pass in tuple that contains the
new start favourite and the username in that order"""
with sqlite3.connect("database.db") as db:
cursor=db.cursor()
sql="update User set StartFavourite=? where UserName=?"
cursor.execute(sql,value)
db.commit()
return True
def EditFinishFavourite(value):
"""function to edit username,
pass in tuple that contains the
new finish favourite and the username in that order"""
with sqlite3.connect("database.db") as db:
cursor=db.cursor()
sql="update User set FinishFavourite=? where UserName=?"
cursor.execute(sql,value)
db.commit()
return True
def EditStartLast(value):
"""function to edit username,
pass in tuple that contains the
new start last and the username in that order"""
with sqlite3.connect("database.db") as db:
cursor=db.cursor()
sql="update User set StartLast=? where UserName=?"
cursor.execute(sql,value)
db.commit()
return True
def EditFinishLast(value):
"""function to edit username,
pass in tuple that contains the
new finish last and the username in that order"""
with sqlite3.connect("database.db") as db:
cursor=db.cursor()
sql="update User set FinishLast=? where UserName=?"
cursor.execute(sql,value)
db.commit()
return True
def main():
a=EditUsername(("TotallyNotAwesome","TotallyNotJiminy"))
with sqlite3.connect("database.db") as db:
cursor=db.cursor()
sql="select * from User where UserName=?"
cursor.execute(sql,("TotallyNotAwesome",))
print(cursor.fetchall())
if __name__=="__main__":
main()