-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctionalities.py
More file actions
64 lines (59 loc) · 1.83 KB
/
Copy pathfunctionalities.py
File metadata and controls
64 lines (59 loc) · 1.83 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
import mysql.connector, hashlib
from mysql.connector import Error
from flask import flash
def connection():
return mysql.connector.connect(
host = "localhost",
user ="root",
password = "",
database = "ProjectDB"
)
conn = connection()
myCursor = conn.cursor()
def encrypt(password):
hash_object = hashlib.md5(password.encode())
return hash_object.hexdigest()
def verifyLogin(email, password):
try:
myCursor.execute("select * from users where Email=%s AND Pass=%s",(email,password))
res = myCursor.fetchall()
if(bool(res)):
return True
else:
flash("Invalid Credentials!","error")
return False
except Error as e:
flash(e,"error")
return False
def addUser(email, pwd1, pwd2):
if pwd1!=pwd2:
flash("Password is not matching!")
return False
else:
try:
myCursor.execute("insert into users(email,pass) values(%s,%s)",(email,pwd1))
conn.commit()
flash("User added")
return True
except:
flash("Email alrerady in use")
return False
def getComplaints():
try:
myCursor.execute("select * from dataset ORDER BY Complains DESC LIMIT 20 ")
res = myCursor.fetchall()
myCursor.reset()
return res
except Error as e:
flash(e,"error")
return ()
def putComplain(complainString, result, email):
try:
val = (complainString,) + tuple(result) + (email,)
myCursor = conn.cursor()
myCursor.execute("insert into dataset values(%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)",val)
# conn.commit() //do not uncomment in development (only for production use)
flash("Submitted Succesfully","success")
except Error as e:
conn.rollback()
flash(e,"error")