You are on page 1of 14

import mysql.

connector
def chemist_shop()

f=mysql.connector.connect(host='localhost',user='root',passwd='321')
b=f.cursor()
b.execute('CREATE DATABASE CHEMIST_SHOP')
f.commit()

f=mysql.connector.connect(host='localhost',user='root',passwd='321')
b=f.cursor()
b.execute('CREATE DATABASE CUSTOMERS')
f.commit()

f=mysql.connector.connect(host="localhost",user='root',passwd='321',dat
abase='CHEMIST_SHOP')
'''b=f.cursor()
b.execute('CREATE TABLE MIDICINES(SNO int(3),NAME
CHAR(20),PRICE int(5));')'''

c=mysql.connector.connect(host='localhost',user='root',passwd='321',data
base='CUSTOMERS')
q=f.cursor()

chemist_shop()

def cc1()
i=[]
r1=int(input("enter sno. "))
i.append(r1)
r2=input("enter item ")
i.append(r2)
r3=int(input("enter price "))
i.append(r3)
R=("insert into MEDICINES values(%s,%s,%s)")
q.execute(R,i)
c.commit()
def cc2()
i=input("name of item u want to remove ")
R=("delete from MEDICINES where name='{}'".format(i))
q.execute(R)
c.commit()

def cc3()
i=input("enter the item which u want to update ")
r1=input("enter the new name of item ")
r2=int(input("enter the price "))
R=("update MEDICINES set name='{}',price={} where
name='{}'".format(r1,r2,i))
q.execute(R)
c.commit()

def cc4()
i=input("enter the item name u want to search ")
R=("select*from MEDICINES where name=%s")
v=(i,)
q.execute(R,v)
r=q.fetchall()
for i in r:
print(i)
def cc5()
q.execute("select * from MEDICINES order by sno")
R=q.fetchall()
print(' '+'_'*32)
print("%s%-6s%-19s%-4s%2s"%('|','sno.','|item','|price','|'))
print('|'+'_'*6+'|'+'_'*18+'|'+'_'*6+'|')
for i in R:
print("%s%-6s%-19s%-4s%4s"%
('|',str(i[0]),'|'+str(i[1]),'|'+str(i[2]),'|'))
print('|'+'_'*6+'|'+'_'*18+'|'+'_'*6+'|')

def cc6()
print()
print(" To Order a MEDICINES")
q.execute("select * from MEDICINES order by sno")
R=q.fetchall()
print(' '+'_'*32)
print("%s%-6s%-19s%-4s%2s"%('|','sno.','|name','|price','|'))
print('|'+'_'*6+'|'+'_'*18+'|'+'_'*6+'|')
for i in R:
print("%s%-6s%-19s%-4s%4s"%
('|',str(i[0]),'|'+str(i[1]),'|'+str(i[2]),'|'))
print('|'+'_'*6+'|'+'_'*18+'|'+'_'*6+'|')
print()
print()

hh=0
gg=0
while(hh==0):
t=int(input("enter the MEDICINES no u want to purchase "))
R="select * from MEDICINES where sno=%s"
p=(t,)
q.execute(R,p)
r=q.fetchall()
for j in r:
print(j)
z=int(j[2])
print()
qty=int(input("HOW MANY: "))
total=qty*z
print()
print("total price is ",total)
print()
gg=gg+total
hh=int(input("do u want to ORDER more ? press 0 to continue
or 1 to exit"))
print()
print("Final amount of ORDER",gg)
print()
def NEW_BILL()
l=0
while l==0:
print()
print("1.add new record")
print("2.delete a record")
print("3.update a record")
print("4.search a record")
print("5.display all record")
print("6.placing a order and Bill calculation")
print("7.exit")

cc=int(input("enter the no. of your choice"))


print()
if(cc==1):
cc1()

elif(cc==2):
cc2()
elif(cc==3):

cc3()

elif(cc==4):
cc4()

elif(cc==5):
cc5()

elif(cc==6):
cc6()

elif(cc==7):
l=l+1

else:
print("choose choices from 1 to 7 ")
chemist_shop()

OUTPUT
============================= RESTART: C:\Users\Erose\AppData\
Local\Programs\Python\Python311\ff.py
=============================

Chemist_shop()

NEW_BILL()
1.add new record
2.delete a record
3.update a record
4.search a record
5.display all record
6.placing a order and Bill calculation
7.exit
enter the no. of your choice 1

enter sno. 1
enter item COUGH SYRUP
enter price 280

1.add new record


2.delete a record
3.update a record
4.search a record
5.display all record
6.placing a order and Bill calculation
7.exit
enter the no. of your choice 1

enter sno. 2
enter item NIMESULIDE
enter price 245

1.add new record


2.delete a record
3.update a record
4.search a record
5.display all record
6.placing a order and Bill calculation
7.exit
enter the no. of your choice 1

enter sno. 3
enter item PARACETAMOL
enter price 280
1.add new record
2.delete a record
3.update a record
4.search a record
5.display all record
6.placing a order and Bill calculation
7.exit
enter the no. of your choice 1

enter sno. 4
enter item ASPIRIN
enter price 345

1.add new record


2.delete a record
3.update a record
4.search a record
5.display all record
6.placing a order and Bill calculation
7.exit
enter the no. of your choice 1

enter sno. 5
enter item ATENOLOL
enter price 415
1.add new record
2.delete a record
3.update a record
4.search a record
5.display all record
6.placing a order and Bill calculation
7.exit
enter the no. of your choice 5

________________________________
|sno. |item |price |
|______|__________________|______|
|1 | COUGH SYRUP |280 |
|______|__________________|______|
|2 | NIMESULIDE |245 |
|______|__________________|______|
|3 | PARACETAMOL |280 |
|______|__________________|______|
|4 | ASPIRIN |345 |
|______|__________________|______|
|5 | ATENOLOL |415 |
|______|__________________|______|

1.add new record


2.delete a record
3.update a record
4.search a record
5.display all record
6.placing a order and Bill calculation
7.exit
enter the no. of your choice 2

name of item u want to remove COUGH SYRUP

1.add new record


2.delete a record
3.update a record
4.search a record
5.display all record
6.placing a order and Bill calculation
7.exit
enter the no. of your choice 5

________________________________
|sno. |item |price |
|______|__________________|______|
|1 | COUGH SYRUP |280 |
|______|__________________|______|
|2 | NIMESULIDE |245 |
|______|__________________|______|
|3 | PARACETAMOL |280 |
|______|__________________|______|
|4 | ASPIRIN |345 |
|______|__________________|______|
|5 | ATENOLOL |415 |
|______|__________________|______|

1.add new record


2.delete a record
3.update a record
4.search a record
5.display all record
6.placing a order and Bill calculation
7.exit
enter the no. of your choice 3

enter the item which u want to update PARACETAMOL


enter the new name of item Acetaminophen
enter the price 280

1.add new record


2.delete a record
3.update a record
4.search a record
5.display all record
6.placing a order and Bill calculation
7.exit
enter the no. of your choice 5

________________________________
|sno. |item |price |
|______|__________________|______|
|1 | COUGH SYRUP |280 |
|______|__________________|______|
|2 | NIMESULIDE |245 |
|______|__________________|______|
|3 | Acetaminophen |280 |
|______|__________________|______|
|4 | ASPIRIN |345 |
|______|__________________|______|
|5 | ATENOLOL |415 |
|______|__________________|______|
1.add new record
2.delete a record
3.update a record
4.search a record
5.display all record
6.placing a order and Bill calculation
7.exit
enter the no. of your choice 4

enter the item name u want to search ASPIRIN


(5, ' ASPIRIN, 415)

1.add new record


2.delete a record
3.update a record
4.search a record
5.display all record
6.placing a order and Bill calculation
7.exit
enter the no. of your choice 6

To Order a BEVERAGE
________________________________
|sno. |item |price |
|______|__________________|______|
|1 | COUGH SYRUP |280 |
|______|__________________|______|
|2 | NIMESULIDE |245 |
|______|__________________|______|
|3 | Acetaminophen |280 |
|______|__________________|______|
|4 | ASPIRIN |345 |
|______|__________________|______|
|5 | ATENOLOL |415 |
|______|__________________|______|

enter the BEVERAGE no u want to purchase 2


(2, ' NIMESULIDE ', 245)

FOR HOW MANY PEOPLE: 4


total price is 980

do u want to ORDER more ? press 0 to continue or 1 to exit0

enter the BEVERAGE no u want to purchase 5


(5, ATENOLOL, 415)

FOR HOW MANY PEOPLE: 1

total price is 415

do u want to ORDER more ? press 0 to continue or 1 to exit1

Final amount of ORDER 1395

1.add new record


2.delete a record
3.update a record
4.search a record
5.display all record
6.placing a order and Bill calculation
7.exit
enter the no. of your choice 7

You might also like