0% found this document useful (0 votes)
16 views

Python Project

Uploaded by

shloktrivedi04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
16 views

Python Project

Uploaded by

shloktrivedi04
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

import mysql.

connector as my

m=my.connect(host="localhost",user="root",passwd="",database="lps",charset="utf8")

######################################

def push():

cur=m.cursor()

n=input("Enter the student name")

r=int(input("Enter the student admission number."))

x=search_exist(r)

if x==1:

print("Sorry invalid ad_no")

return

a=input("Enter the student address")

st="insert into stu (s_name,ad_no,address) values('{}',{},'{}')".format(n,r,a)

cur.execute(st)

m.commit()

####################################

def search():

cur=m.cursor()

r=int(input("Enter the student addmission number."))

st="select * from stu where ad_no=%s" %(r,)

cur.execute(st)

da=cur.fetchall()

for r in da:

print(r)

####################################
def dele(p):

x=search_exist(p)

if x==0:

print("Sorry invalid ad_no")

return

cur=m.cursor()

st="delete from stu where ad_no=%s" %(p,)

cur.execute(st)

m.commit()

#############################################

def display():

cur=m.cursor()

st="select * from stu"

cur.execute(st)

da=cur.fetchall()

for j in da:

print(j)

####################################

####################################

def search_exist(r):

cur=m.cursor()

st="select ad_no from stu where ad_no=%s" %(r,)

cur.execute(st)

da=cur.fetchall()

for j in da:
if j[0]==r:

return 1

return 0

####################################

print("School Management System")

i=1

while i==1:

print("press 1 for enroll no.")

print("press 2 for search")

print("press 3 for delete")

print("press 4 for display records")

print("press 5 for exit")

x=int(input("Enter ur choice"))

if x==1:

push()

elif x==2:

search()

elif x==3:

d=int(input("Enter the left out roll no."))

dele(d)

elif x==4:

display()

elif x==5:

break

i=int(input("Do u want more press 0 for exit and 1 for exit"))

#################################

You might also like