-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdb_update.py
More file actions
110 lines (101 loc) · 4.21 KB
/
db_update.py
File metadata and controls
110 lines (101 loc) · 4.21 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
import pyodbc
import db_query as dbq
import datetime
class Update:
def __init__(self):
self.db = pyodbc.connect(
'Driver={ODBC Driver 17 for SQL Server};'
'Server=sql.athena.domainhizmetleri.com;'
'Database=abdullah_pys;'
'UID=abdullah_pys;'
'PWD=@PassWord123;'
)
def PasswordChange(self,no,old_pass,new_pass):
query = dbq.Query()
try:
result = query.login_query(no,old_pass)
if result == "student":
cursor = self.db.cursor()
cursor.execute("UPDATE m_Student SET password = ? WHERE studentID = ? AND password = ?", no, no,old_pass)
self.db.commit()
return "Successful"
elif result == "advisor":
cursor = self.db.cursor()
cursor.execute("UPDATE m_Advisor SET password = ? WHERE registrationID = ? AND password = ?", no, int(no),old_pass)
self.db.commit()
return "Successful"
elif result == "admin":
cursor = self.db.cursor()
cursor.execute("UPDATE m_superAdmin SET password = ? WHERE mail = ? AND password = ?", no, no,old_pass)
self.db.commit()
return "Successful"
else:
return "False"
except Exception as e:
e = str(e)
return e
def projectStatusUpdate(self,proje_no,new_status,old_status,desc,date):
try:
cursor = self.db.cursor()
cursor.execute("UPDATE t_Projects SET status = ?,description = ?, updatedDate = ? WHERE number = ? AND status = ?", int(new_status), desc,date,proje_no,int(old_status))
self.db.commit()
return "Successful"
except Exception as e:
e = str(e)
return e
def reportsStatusUpdate(self,id,new_status,desc):
try:
date = datetime.datetime.now()
cursor = self.db.cursor()
cursor.execute("UPDATE t_reports SET status = ?,description = ?, updatedDate = ? WHERE id = ?",
int(new_status), desc,date,id)
self.db.commit()
return "Successful"
except Exception as e:
e = str(e)
return e
def projectPlagiarismUpdate(self,proje_no):
try:
cursor = self.db.cursor()
cursor.execute("UPDATE t_Projects SET status = ?,description = ? WHERE number = ? ", 5, "İntihal tespit edildi",proje_no)
self.db.commit()
return "Successful"
except Exception as e:
e = str(e)
return e
def projectNewPlagiarismUpdate(self,proje_no,plag):
try:
cursor = self.db.cursor()
cursor.execute("UPDATE t_Projects SET maxPlagiarism = ? WHERE number = ? ", plag,proje_no)
self.db.commit()
return "Successful"
except Exception as e:
e = str(e)
return e
def dissertationStatusUpdate(self,id,new_status,desc):
try:
date = datetime.datetime.now()
cursor = self.db.cursor()
cursor.execute("UPDATE t_Dissertation SET status = ?,description=?,updatedDate=? WHERE id = ?",
new_status,desc,date,id)
self.db.commit()
return "Successful"
except Exception as e:
e = str(e)
return e
def projectStatusUpRed(self,projeno):
try:
cursor = self.db.cursor()
cursor.execute("UPDATE t_Projects SET status = ?,description=? WHERE number = ?",
5,"intihal tespit edildi",projeno)
self.db.commit()
return "Successful"
except Exception as e:
e = str(e)
return e
# nesne = Update()
# print(nesne.dissertationStatusUpdate("1119881",0,2,"yeni acıklama"))
# print(nesne.projectNewPlagiarismUpdate("1119416",14))
# date = datetime.datetime.now()
# print(nesne.projectStatusUpdate("1124835",3,1,"yeni update",date))
# print(nesne.PasswordChange("pys@abdullahaligun.com","admin","yeninew4"))