import mysql.
connector
mydb = [Link](host="localhost", user="root", password="akarsh05")
cr = [Link]()
q = "drop database medicine_shop"
[Link](q)
q = "create database medicine_shop"
[Link](q)
q = "use medicine_shop"
[Link](q)
q = '''create table medicine(
mid integer primary key,
mname varchar(30) not null,
manufacturer varchar(50),
dateofm date,
dateofexp date not null,
mg float,
content varchar(100),
price float,
qty integer)'''
[Link](q)
q = '''
create table bill(
billid integer primary key,
cname varchar(50),
medicine_bought varchar(100),
amount float,
billdate date)'''
[Link](q)
[Link]()
print("Database Initialised")
# library import
import [Link] as sql
import time
import random as rd
def medicine():
# function to add a medicine
def addmedicine():
print("\n")
print("😇🙃" * 15)
print("\n")
mid = input("Enter Medicine Id : ")
name = input("Enter Medicine Name : ")
mf = input("Enter Name of Manufacturer : ")
dom = input("Enter Date of Manufacture : ")
doe = input("Enter Date of Expiry : ")
mg = input("Enter the Weight (in mg) : ")
content = input("Enter Content : ")
price = input("Enter the Price : ")
qty = input("Enter the Quantity : ")
print("\nSTORING MEDICINE DETAILS.......")
[Link](2)
q = "insert into medicine values(%s,%s,%s,%s,%s,%s,%s,%s,%s)"
data = (mid, name, mf, dom, doe, mg, content, price, qty)
cr = [Link]()
[Link](q, data)
print("\nMedicine Inserted.......!!!!")
😎 * 15)
print(""
print("\n")
[Link]()
# function to show a medicine
def showmedicine():
😄 * 15)
print(""
q = "select * from medicine"
cr = [Link]()
[Link](q)
res = [Link]()
print("\n")
print("-" * 95)
print("Id\tName\t\tDate_of_Expiry\t\tPrice\t\tQty")
print("-" * 95)
for k in res:
print(k[0], "\t", k[1], "\t\t", k[4], "\t\t", k[-2], "\t\t", k[-1])
print("-" * 95)
print("\n")
# function to restock a medicine
def restock():
mid = input("Enter the Medicine ID : ")
qty = input("Enter the Quantity to Add : ")
q = "update medicine set qty = qty + %s where mid = %s"
d = (qty, mid)
cr = [Link]()
[Link](q, d)
print("\n")
print("😎😄" * 12)
print("Medicine Restocked......!!")
print("😎😄" * 12)
print("\n")
[Link]()
# function to search a medicine
def search():
mid = input("Enter the Medicine ID : ")
q = "select * from medicine where mid = " + mid
cr = [Link]()
[Link](q)
k = [Link]()
if k == None:
print("\nNo Medicine Available With This ID\n")
print("😣😣" * 15)
else:
print("\nMedicine Found......!!")
print("😀😀" * 15)
print("\n")
print("-" * 95)
print("Id\tName\t\tDate_of_Expiry\t\tPrice\t\tQty")
print("-" * 95)
print(k[0], "\t", k[1], "\t\t", k[4], "\t\t", k[-2], "\t\t", k[-1])
print("-" * 95)
print()
# Function to delete a medicine
def deletem():
mid = input("Enter the Medicine ID : ")
q = "delete from medicine where mid = " + mid
cr = [Link]()
[Link](q)
print("\nMedicine Deleted......!!\n")
print("😒😒" * 15)
print("\n\n")
[Link]()
# function for billing
def billing():
bno = input("Enter Bill No. : ")
cname = input("Enter Customer's Name : ")
bdate = input("Enter Bill Date (yyyy-mm-dd) : ")
amount = 0
medicine =""
cr = [Link]()
while True:
mid = input("Enter Medicine id : ")
q = "select * from medicine where mid = " + mid
[Link](q)
res = [Link]()
if res == None:
print("\nNo Medicine Available With This ID\n")
print("😣😣" * 15)
else:
price = int(res[-2])
medicine += res[1] + " "
print("Price of Medicine is : ", price)
qty = int(input("Enter the Quantity to be Purchased : "))
bill = price * qty
amount += bill
print("Amount for Medicine ", amount)
ans = input("Are There More Medicine to be Purchased : ")
if [Link]() == "no":
print("Calculating Your Bill ")
break
print("Total Bill Amount is : ", amount)
q = "insert into bill values(%s,%s,%s,%s,%s)"
data= (bno,cname,medicine,amount,bdate)
[Link](q,data)
[Link]()
print(" Bill Generated !!! \n\n")
def showbills():
print(""😄 * 15)
q = "select * from bill"
cr = [Link]()
[Link](q)
res = [Link]()
print("\n")
print("-" * 95)
print("BillNo\tName\t\tMedicine\t\t\t\tAmount\t\tDateofBill")
print("-" * 95)
for k in res:
print(k[0], "\t", k[1], "\t\t", k[2], "\t\t", k[3], "\t\t", k[4])
print("-" * 95)
print("\n")
while True:
print("😇🙃" * 15)
print("\t\t\tAL Medical Store")
print("😇🙃" * 15)
print("\n")
print("Press 1 - Add New Medicine")
print("Press 2 - Restock a Medicine")
print("Press 3 - Show All Medicines")
print("Press 4 - Search a Medicine")
print("Press 5 - Delete a Medicine")
print("Press 6 - Billing")
print("Press 7 - Display Previous Bills")
print("press 8 - to Exit")
print("\n")
opt = int(input("Enter Your Choice : "))
if opt == 1:
addmedicine()
elif opt == 2:
restock()
elif opt == 3:
showmedicine()
elif opt == 4:
search()
elif opt == 5:
deletem()
elif opt == 6:
billing()
elif opt == 7:
showbills()
elif opt == 8:
print("THANKS FOR VISITING..!!")
print("✌😄" * 15)
print("\t\t Have a Medicine-Free Life Ahead")
print("*" * 95)
break
else:
print("You're having only 8 options to choose -___-")
break
# setting conection
mydb = [Link](host="localhost", user="root", password="akarsh05",
database="medicine_shop")
# login screen
a = [Link](1, 9)
b = [Link](1, 9)
c = [Link](1, 9)
d = [Link](1, 9)
e = [Link](1, 9)
num = str(a) + str(b) + str(c) + str(d) + str(e)
print("\t\t", num)
n = int(input("Enter The Number Shown Above : "))
if str(n) == num:
print("Yayyyiieee...You've Successfully Entered the Market..!!")
if mydb.is_connected():
print("🥳🥳🎁" * 10)
print("\n")
print("\t\t\tCHEMIST SHOP MANAGEMENT")
print("\n")
print("🥳🥳🎁" * 10)
medicine()
🙃 * 15)
print(""
print("\t\tThanks for Visiting....!!!")
🙃 * 15)
print(""
else:
print("Connection Error !!!!!")
else:
print("Seems like it's not a human being -__-")
print("You Can't Enter The Software. SORRY >_____<")