Professional Documents
Culture Documents
Ip Proj
Ip Proj
Ip Proj
connector
mydb = mysql.connector.connect(host="localhost",user="prs",passwd="123",database="project")
con=mydb.cursor()
#con.execute("use project")
def loginput():
def signup():
loginput()
val=(u,p)
con.execute(sql,val)
mydb.commit()
val = (u,nam,dob,addrs)
con.execute(sql,val)
mydb.commit()
def menu():
print ("Select from the following alternatives..")
print ("4 : View Current Count(ONLY IF ALREADY CASTED YOUR VOTE) \n" )
def update():
z=int(input())
if z==1:
val=(nam,u)
con.execute(sq,val)
mydb.commit()
if z==2:
val=(dob,u)
con.execute(sq,val)
mydb.commit()
if z==3:
val=(addrs,u)
con.execute(sq,val)
mydb.commit()
d=con.fetchall()
n=u%1000
l1=d[n-1]
print("Name : ",l1[1])
print("DOB : ",l1[2])
print("Address : ",l1[3])
def vote():
l1=("T")
val=(u)
con.execute(sql,val)
l2=con.fetchall()
if l2==l1:
menu()
else:
m=int(input())
val=("T",u)
con.execute(sq,val)
mydb.commit()
if m==1:
val="A"
con.execute(sq,val)
mydb.commit()
if m==2:
con.execute(sq,val)
mydb.commit()
if m==3:
val="C"
con.execute(sq,val)
mydb.commit()
if m==4:
val="NOTA"
con.execute(sq,val)
mydb.commit()
def votecount():
if l2==l1:
data=con.fetchall()
for x in data:
print(x)
else:
print("You haven't casted your vote yet. Please cast your vote to view this information.\n")
k=0
if n==2:
signup()
if n==1:
loginput()
l=(u,p)
data=con.fetchall()
for x in data:
if x==l:
k=1
if k==1:
print("Logged in succesfully...\n")
menu()
y=int(input())
if y==1:
view()
if y==2:
update()
if y==3:
print("Select one out of the foolowing alternatives\n1. Party A\n2. Party B\n3. Party C\\n4.
NOTA")
vote()
if y==4:
votecount()
if y==5:
break
else: