0% found this document useful (0 votes)
19 views11 pages

Stock Management Codding and Output Documentation

computer science class 12th.

Uploaded by

walkwithabhi2525
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)
19 views11 pages

Stock Management Codding and Output Documentation

computer science class 12th.

Uploaded by

walkwithabhi2525
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/ 11

CODING

import os
import platform
import mysql.connector
mydb=mysql.connector.connect(host="localhost",\
user="root",\
passwd="root",\
database="School")
mycursor=mydb.cursor()
def stuInsert():
L=[]
roll=int(input("Enter the roll number : "))
L.append(roll)
name=input("Enter the Name: ")
L.append(name)
age=int(input("Enter Age of Student : "))
L.append(age)
classs=input("Enter the Class : ")
L.append(classs)
city=input("Enter the City ofthe Student : ")
L.append(city)
stud=(L)
sql="insert into student (roll,name,age,class,city) values
(%s,%s,%s,%s,%s)"
1
My Project …….
mycursor.execute(sql,stud)
mydb.commit()
def stuView():
print("Select the search criteria : ")
print("\t"*5 ,"1. Roll")
print("\t"*5 ,"2. Name")
print("\t"*5 ,"3. Age")
print("\t"*5 ,"4. City")
print("\t"*5 ,"5. All")
ch=int(input("\t\t\t\t\tEnter the choice ....... : "))
if ch==1:
s=int(input("Enter roll no : "))
rl=(s,)
sql="select * from student where roll=%s"
mycursor.execute(sql,rl)
elif ch==2:
s=input("Enter Name : ")
rl=(s,)
sql="select * from student where name=%s"
mycursor.execute(sql,rl)
elif ch==3:
s=int(input("Enter age : "))
rl=(s,)
sql="select * from student where age=%s"
2
My Project …….
mycursor.execute(sql,rl)
elif ch==4:
s=input("Enter City : ")
rl=(s,)
sql="select * from student where City=%s"
mycursor.execute(sql,rl)
elif ch==5:
sql="select * from student"
mycursor.execute(sql)
res=mycursor.fetchall()
print("The Students details are as follows : ")
print("(ROll, Name, Age, Class, City)")
for x in res:
print(x)
def feeDeposit():
L=[]
roll=int(input("Enter the roll number : "))
L.append(roll)
feedeposit=int(input("Enter the Fee to be deposited : "))
L.append(feedeposit)
month=input("Enter month of fee : ")
L.append(month)
fee=(L)
sql="insert into fee (roll,feeDeposit,Month) values (%s,%s,%s)"
3
My Project …….
mycursor.execute(sql,fee)
mydb.commit()
def feeView():
print("Please enter the details to view the fee details :")
roll=int(input("Enter the roll number of the student whose fee is to be
viewed : "))
sql="Select Student.Roll, Student.Name, Student.Class,
sum(fee.feeDeposit), fee.month from Student \
INNER JOIN fee ON Student.roll=fee.roll and fee.roll = %s"
rl=(roll,)
mycursor.execute(sql,rl)
res=mycursor.fetchall()
for x in res:
print(x)
def removeStu():
roll=int(input("Enter the roll number of the student to be deleted : "))
rl=(roll,)
sql="Delete from fee where roll=%s"
mycursor.execute(sql,rl)
sql="Delete from Student where roll=%s"
mycursor.execute(sql,rl)
mydb.commit()
def table_manage():
while True :
print("\t\t\t 1. Tables creation")
4
My Project …….
print("\t\t\t 2. List Table")
print("\t\t\t 3. Back (Main Menu)")
p=int (input("\t\tEnter Your Choice :"))
if p==1 :
create_tables()
if p==2 :
list_table()
if p== 3 :
break
def create_tables():
print(" Creating student table")
sql = "create table student (roll int(5) primary key,name
varchar(25),age int(2),class varchar(3),city varchar(25))"
mycursor.execute(sql)
print(" Creating fee table")
sql = "create table fee (roll int(5),feeDeposit int(6),Month
varchar(20))"
mycursor.execute(sql)
def list_table():
sql="show tables;"
mycursor.execute(sql)
for i in mycursor:
print(i)

def MenuSet(): #Function For The Student Management System


5
My Project …….
print("\t"*5 ,"Enter 1 : To Add Student")
print("\t"*5 ,"Enter 2 : To View Student ")
print("\t"*5 ,"Enter 3 : To Deposit Fee ")
print("\t"*5 ,"Enter 4 : To Remove Student")
print("\t"*5 ,"Enter 5 : To View Fee of Any Student")
print("\t"*5 ,"Enter 6 : To Table Managment...")

try: #Using Exceptions For Validation


userInput = int(input("\t\t\t\tPlease Select An Above Option: "))
#Will Take Input From User
except ValueError:
exit("\nHy! That's Not A Number") #Error Message
else:
print("\n") #Print New Line
if(userInput == 1):
stuInsert()
elif (userInput==2):
stuView()
elif (userInput==3):
feeDeposit()
elif (userInput==4):
removeStu()
elif (userInput==5):
feeView()

6
My Project …….
elif (userInput==6):
table_manage()
else:
print("Enter correct choice. . . ")
MenuSet()
def runAgain():
runAgn = input("\nwant To Run Again Y/n: ")
while(runAgn.lower() == 'y'):
if(platform.system() == "Windows"):
print(os.system('cls'))
else:
print(os.system('clear'))
MenuSet()
runAgn = input("\nwant To Run Again Y/n: ")
runAgain()

7
My Project …….
Output Screens
Main Menu

Tables…..

8
My Project …….
Insert Data…

Show Record…

9
My Project …….
BIBLIOGRAPHY

➢ http://www.google.com/
➢ http://en.wikipedia.org
➢ Informatics Practices with Python by Preeti Arora
➢ Informatics Practices textbook for class XII by Sumita Arora
➢ https://www.geeksforgeeks.org/

10
My Project …….
Reemarrk Sheet


 ……….

11
My Project …….

You might also like