You are on page 1of 20

Name :- Devesh Singh & Lakshay

Class :- XII-A

Roll No. :- 05 and 09

Board Roll no. :- 14627249 & 14627253

Subject teacher :- Mrs. Neelam Gupta Ma’am


(Computer science)
KENDRIYA VIDHYALAYA
NO. 2
DELHI CANTT-10
CERTIFICATE
This is to certify that DEVESH SINGH & LAKSHAY
students of class XII-A has successfully carried out the
project entitled “programming” under the supervision of
Computer science teacher Mrs. Neelam Gupta
Ma’am(Subject teacher) during the year of 2019-20.

All the works related to the project is done by the candidate


himself. The approach towards the subject has been sincere
and scientific.
Signature of Computer Science teacher :-

Acknowledgement
In the accomplishment of this project successfully,
many people have best owned upon me their
blessings and the heart pledged support, this time I
am utilizing to thank all the people who have been
conserved with project.

Primarily I would thank god for being able to


complete project with success. Then I would like to
thank my Computer science teacher Mrs. Neelam
Gupta ma’am, whose valuable guidance has been the
ones that helped me patch this project and make it
full proof success his suggestions towards the
completion of the project.

Then I would like to thank my parents who helped


me with their valuable suggestions and guidance has
helpful in various phases of the completion of the
project.

Student signature :-

Index
1. Certificate of Excellence
2. Acknowledgement
3. Menu driven Programs
4. Bibliography
DBMS : MYSQL
HOST: LOCAL HOST
USER:ROOT
PASSWORD :OIS
DATABSE : CS
TABLE STRUCTURE : AS GIVEN BELOW
#MYSQL COMMANDS:-

create database cs;


use cs;
create table DL_Hospital(disease varchar(30),treatment
varchar(35),fee_required int,icu_ward int);

insert into DL_Hospital values("hernia","laproscopic_surgery",70000,101);


insert into DL_Hospital values(" cancer","radiation_therapy",500500,129);
insert into DL_Hospital values("blood_pressure","thiazide_duretic",9999,54);
insert into DL_Hospital values("diabetes","glycemic",45000,136);
insert into DL_Hospital values("asthma","theophylline",850000,69);
insert into DL_Hospital values("liver_disease","acetylcysteine",69000,42);
insert into DL_Hospital values("viral_fever","bedrest",5000,137);

create table DL_Hospital(ptnt_name varchar(30),disease


varchar(35),occupation varchar(20),address varchar(15),age int);

insert into ptnt_data values("manisha","viral_fever","doctor","dehradun",20);


insert into ptnt_data values("devesh","diabetes","engineer","noida",20);
insert into ptnt_data values("geeti","piles","farmer","dwarka",69);
insert into ptnt_data values("prashant","hernia","unemployed","jj_colony",99);
insert into ptnt_data values("cynthia","cancer","actress","los angles",18);
insert into ptnt_data values("lakshay","asthma","builder","gurugram",35);
#python program:-

import mysql.connector as m
import sys
#to connect mysql database with python
man=m.connect(host="localhost",user="root",passwd="ois",database="cs")
cursor=man.cursor()
#to check database is connected or not
if (man.is_connected):
print("connection established")
else:
print("connection not establishes")
#MENu
print("1:- TO SHOW ALL EXISTING TABLES")
print("2:-TO DESCRIBE THE TABLE CREATED FOR PROJECT")
print("3:-TO DISPLAY THE DATA OF CREATED TABLE")
print("4:-TO ADD NEW RECORD IN TABLE")
print("5:-TO SEARCH ANY DETAIL FROM TABLE")
print("6:-TO CHANGE ANY DETAIL FROM TABLE")
print("7:-TO DELETE ANY DETAIL FROM TABLE")
print("8:-TO EXIT")
while(1):
ch=int(input(" enter your choice"))
#TO SHOW ALL EXISTING TABLES
if ch==1:
cursor.execute("show tables")
for i in cursor:
print (i)
#TO DESCRIBE THE TABLE CREATED FOR PROJECT
if ch==2:
print("1:-To describe hospital table")
print("2:-To describe patient table")
k=int(input("enter your choice whose data has to be printed"))
if k==1:
cursor.execute("desc DL_Hospital")
for i in cursor:
print(i)
else:
cursor.execute("desc ptnt_data")
for i in cursor:
print(i)
#TO DISPLAY THE DATA OF CREATED TABLE
if ch==3:
print("1:-To print data of hospital table")
print("2:-To print data of patient table")
k=int(input("enter your choice whose data has to be printed"))
#To print data of hospital table
if k==1:
cursor.execute("select * from DL_Hospital")
data=cursor.fetchall()
print("Disease","Treatment","Price")
for i in data:
j=str(i).split()
for k in j:
print(k,end=" ")
print()
#To print data of patient table
elif k==2:
cursor.execute("select * from ptnt_data")
data=cursor.fetchall()
print("Disease","Treatment","fee_required","icu_ward")
for i in data:
j=str(i).split()
for k in j:
print(k,end=" ")
print()
else:
print("no more tables")
#TO ADD NEW RECORD IN TABLE
if ch==4:
dis=input("enter name of disease")
treat=input("enter the treatment")
pz=int(input("enter the price"))
icu=int(input("enter the icu ward number"))
query="insert into DL_Hospital values(%s,'%s',%d,%d)"%(dis,treat,pz,icu)
cursor.execute(query)
man.commit()
#TO SEARCH ANY DETAIL FROM TABLE
if ch==5:
print("1:-To print data of hospital table")
print("2:-To print data of patient table")
k=int(input("enter your choice whose data has to be printed"))
if k==1:
print("1:- to search detail by disease")
print("2:- to search detail by ward_no")
n=int(input("enter your choice"))
if n==1:
dis=input("enter disease whose details to be searched")
qry="select * from DL_Hospital where disease={}".format(dis)
cursor.execute(qry)
data=cursor.fetchall()
for i in data:
print(i)
if n==2:
icu=input("enter the ward no whose detail you want to search ")
qry="select * from DL_Hospital where icu_ward={}".format(icu)
cursor.execute(qry)
data=cursor.fetchall()
for i in data:
print(i)
else:
print("please enter choice from above mentioned choices")
else:
print("1:- to search detail by name")
print("2:- to search detail by disease")
n=int(input("enter your choice"))
if n==1:
naam=input("enter patient name whose details to be searched")
qry="select * from ptnt_data where ptnt_name={}".format(naam)
cursor.execute(qry)
data=cursor.fetchall()
for i in data:
print(i)
if n==2:
dis=input("enter detail by disease to search")
qry="select * from ptnt_data where disease={}".format(dis)
cursor.execute(qry)
data=cursor.fetchall()
for i in data:
print(i)
else:
print("please enter choice from above mentioned choices")
#TO CHANGE ANY DETAIL FROM TABLE
if ch==6:
print("1:- to change details from hospital table")
print("2:- to change details from patient table")
y=int(input("enter your choice"))
if y==1:
print("Press 1 to change the name of disease")
print("press 2 to change the fees of treatment")
x=int(input("enter the choice to change any detail"))
if x==1:
newname=input("enter the new name")
dis=input("enter name of disease whose name has to be changed")
qry="update DL_Hospital set disease={} where
disease={}".format(newname,dis)
cursor.execute(qry)

cursor.execute("select * from DL_Hospital")


data=cursor.fetchall()
print("Disease","Treatment","Price")
for i in data:
j=str(i).split()
for k in j:
print(k,end=" ")
print()
else:
newfee=int(input("enter the new price"))
d=input("enter name of disease whose fees has to be changed")
qry="update DL_Hospital set price={} where
disease={}".format(newfee,d)
cursor.execute(qry)

cursor.execute("select * from DL_Hospital")


data=cursor.fetchall()
print("Disease","Treatment","Price")
for i in data:
j=str(i).split()
for k in j:
print(k,end=" ")
print()
if y==2:
print("Press 1 to change the name of patient")
print("press 2 to change the occupation of disease")
x=int(input("enter the choice to change any detail"))
if x==1:
newname=input("enter the new name")
p=input("enter name of disease whose name has to be changed")
qry="update ptnt_data set ptnt_name={} where
disease={}".format(newname,p)
cursor.execute(qry)

cursor.execute("select * from ptnt_data")


data=cursor.fetchall()
print("Disease","Treatment","Price")
for i in data:
j=str(i).split()
for k in j:
print(k,end=" ")
print()
elif x==2:
o=input("enter the name of changed occupation")
name=input("enter name of patient whose occupation has to be
changed")
qry="update ptnt_data set occupation={} where
ptnt_name={}".format(o,name)
cursor.execute(qry)

cursor.execute("select * from ptnt_data")


data=cursor.fetchall()
print("Disease","Treatment","occupation","address","age")
for i in data:
j=str(i).split()
for k in j:
print(k,end=" ")
print()
else:
print("please enter choice from above mentioned choices")
else:
print("please enter choice from above mentioned choices")
#TO DELETE ANY DETAIL FROM TABLE
if ch==7:
print("1:-To delete data of hospital table")
print("2:-To delete data of patient table")
k=int(input("enter your choice whose data has to be deleted"))
#if you want to delete detail from hospital table
if k==1:
dis=input("enter name of disease whose record you want to delete")
qry="delete from DL_Hospital where disease={}".format(dis)
cursor.execute(qry)
cursor.execute("select * from DL_Hospital")
data=cursor.fetchall()
print("Disease","Treatment","Price")
for i in data:
j=str(i).split()
for k in j:
print(k,end=" ")
print()

#if you want to delete detail from patient table


elif k==2:
name=input("enter name of patient you want to delete")
qry="delete from ptnt_data where ptnt_name={}".format(name)
cursor.execute(qry)
cursor.execute("select * from ptnt_data")
data=cursor.fetchall()
print("Disease","Treatment","Price")
for i in data:
j=str(i).split()
for k in j:
print(k,end=" ")
print()
else:
print("no more tables")
#TO EXIT FROM PROGRAM
if ch==8:
sys.exit()

man.close()
Bibliography
 www.google.com
 www.scribd.com
 https://en.wikipedia.org
 www.quora.com
 www.study.com
th
 Sumita Arora python class 12 .

You might also like