Professional Documents
Culture Documents
Name:-Devesh Singh & Lakshay
Name:-Devesh Singh & Lakshay
Class :- XII-A
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.
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:-
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)
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 .