CS Final Project
CS Final Project
NEW DELHI
SUBMITTED TO : SUBMITTED BY :
JOHN MAJOR A. REHAN ZEYA
SACHIN KUMAR
PGT COMPUTER SCIENCE SACHIN KUMAR YADAV
CONTENTS
S.No. TOPIC PAGE NO.
1. COVER PAGE (i)
2. CERTIFICATE (ii)
3. ACKNOWLEDGEMENT (iii)
4. ABSTRACT
5. CODING
6. OUTPUT
7. BIBLIOGRAPHY
OBJECTIVE OF THE PROJECT
ABSTRACT
(5)
CODING
Import mysql.connector as sqltor
mycon=sqltor.connect(host="localhost",user="root",passwd="",charset='utf8',d
atabase="Hindustan_Motors")
if mycon.is_connected():
print("successfully connected")
ch="y"
whilech=='y' or ch=='Y':
print("=======MENU=========")
print("1. Reading the data")
print("2. Writing the data")
print("3. Searching the data")
print("4. Updating the data")
print("5. Deleting the data")
c=int(input("Enter your choice: "))
if c==1:
cursor=mycon.cursor()
cursor.execute("select * from cars")
data=cursor.fetchall()
count=cursor.rowcount
print("=====================")
(7)
print('Total number of rows retrieved: ',count)
for row in data:
print(row)
elif c==2:
company=input('Enter Company of the car: ')
model=input('Enter Model of the car: ')
year=input('Enter Launch year of the car: ')
origin=input('Enter Origin of the car: ')
horsepower= input('Enter horsepower of the car: ')
manuf=int(input('Enter manufacturing id: '))
write="INSERT INTO CARS(Company, Model, Launch_Year, Origin,
Horsepower,manuf_id)VALUES('{}','{}',{},'{}',{},{})".format
(company,model, year,origin,horsepower,manuf)
cursor=mycon.cursor()
cursor.execute(write)
mycon.commit()
print("======INSERTED======")
(8)
elif c==3:
b="y"
while b=='y' or b=='Y':
print('========================')
print("1. Using Company")
print("2. Using Model")
print("3. Using manufacturing id")
x=int(input("Enter your choice: "))
if x==1:
cursor=mycon.cursor()
cursor.execute("select * from cars")
data=cursor.fetchall()
comp=input('enter company: ')
for row in data:
if comp in row:
print(row)
elif x==2:
cursor=mycon.cursor()
cursor.execute("select * from cars")
data=cursor.fetchall()
model=input('enter model: ')
for row in data:
if model in row:
print(row)
(9)
elif x==3:
cursor=mycon.cursor()
cursor.execute("select * from cars")
data=cursor.fetchall()
manuf=int(input('enter manufacturing id: '))
for row in data:
if manuf in row:
print(row)
else:
print('INVALID CHOICE')
b=input("Do You Want To search More(Y/N): ")
elif c==4:
a="y"
while a=='y' or a=='Y':
print('========================')
print("1. Update Company")
print("2. Update Model")
print("3. Update Launch Year")
print("4. Update Origin")
print("5. Update Horsepower")
print("6. Update manufacturing id")
x=int(input("Enter your choice: "))
(10)
if x==1:
manuf=int(input('Enter Manufacturing ID for updating: '))
new=input('enter new company: ')
up=”update cars set company={} where manuf_id={}”
.format(new,manuf)
cursor=mycon.cursor()
cursor.execute(up)
mycon.commit()
print('UPDATED')
elif x==2:
manuf=int(input('Enter Manufacturing ID for
updating: '))
new=input('Enter New Model: ')
up=”update cars set model={} where
manuf_id={}”.format(new,manuf)
cursor=mycon.cursor()
cursor.execute(up)
mycon.commit()
print('UPDATED')
elif x==3:
manuf=int(input('enter manufacturing for updating: '))
new=int(input('enter new year: '))
up=”update cars set launch_year={} where
manuf_id={}”.format(new,manuf)
cursor=myco(1n1.)cursor()
cursor.execute(up)
mycon.commit()
print('UPDATED')
elif x==4:
manuf=int(input('enter manufacturing for updating: '))
new=input('enter new origin: ')
up='update cars set origin={} where
manuf_id={}'.format(new,manuf)
cursor=mycon.cursor()
cursor.execute(up)
mycon.commit()
print('UPDATED')
elif x==5:
manuf=int(input('enter manufacturing for updating: '))
new=input('enter new horsepower: ')
up='update cars set horsepower={} where
manuf_id={}'.format(new,manuf)
cursor=mycon.cursor()
cursor.execute(up)
mycon.commit()
print('UPDATED')
(12)
elif x==6:
manuf=int(input('enter manufacturing for updating: '))
new=input('enter new manufacturing code: ')
up='update cars set manuf_id={} where
manuf_id={}'.format(new,manuf)
cursor=mycon.cursor()
cursor.execute(up)
mycon.commit()
print('UPDATED')
else:
print('INVALID CHOICE')
a=input("Do You Want To Update More(Y/N): ")
elif c==5:
manuf=input('enter manufacturing id of which row is to be deleted: ')
delete="delete from cars where manuf_id={}".format(manuf)
cursor=mycon.cursor()
cursor.execute(delete)
mycon.commit()
print('Deleted')
else:
print("Invalid Choice")
(13)
OUTPUT
1) READING DATA
2) WRITING DATA
(14)
3) SEARCHING DATA
(15)
4) UPDATING DATA
(16)
(ii) UPDATING MODEL:
(17)
(iv) UPDATING ORIGIN:
(18)
(vi) UPDATING MANUFICTURING ID:
5) DELETING DATA
(19)
BIBLIOGRAPHY
1) NCERT TEXTBOOK
(20)