-
Notifications
You must be signed in to change notification settings - Fork 1
/
databaseupdates.py
52 lines (44 loc) · 1.94 KB
/
databaseupdates.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
47
48
49
50
51
52
from database import DB
import pandas as pd
import sys
import os
#Classes for queries regarding updates to the database for the user and admin
class databaseQueries(DB):
def updateUserName(self):
from updateusername import olduserName, newuserName
if self.mydb.is_connected():
resultSet2_1 = ("UPDATE SharkAttackDatabase SET userName = %s WHERE userName = %s")
answer2_1 = (newuserName, olduserName)
mycursor = self.mydb.cursor()
mycursor.execute(resultSet2_1, answer2_1)
self.mydb.commit()
print("User Name Updated")
import userchoice
def updateUserPassword(self):
from updateuserpassword import userName, newUserPassword
if self.mydb.is_connected():
resultSet2_1 = ("UPDATE SharkAttackDatabase SET userPassword = %s, userPassword2 = %s WHERE userName = %s")
answer2_1 = (newUserPassword, newUserPassword, userName)
mycursor = self.mydb.cursor()
mycursor.execute(resultSet2_1, answer2_1)
self.mydb.commit()
print("User Password Updated")
import userchoice
def listUsers(self):
if self.mydb.is_connected():
listUsers = "SELECT user_id, userName FROM SharkAttackDatabase"
mycursor = self.mydb.cursor()
mycursor.execute(listUsers)
resultSet4 = mycursor.fetchall()
for x in resultSet4:
print(x)
def updateDeleteUser(self):
from deleteuser import userName
if self.mydb.is_connected():
resultSet5 = "DELETE FROM SharkAttackDatabase WHERE userName = %s "
answer6 = (userName,)
mycursor = self.mydb.cursor()
mycursor.execute(resultSet5, answer6)
self.mydb.commit()
print("User {} has been deleted.".format(userName))
import adminmenu