Python CODE
Python CODE
connector
def create_connection():
connection = mysql.connector.connect(
host='localhost',
user='root',
password='password',
database='pharmacy_db')
return connection
connection = create_connection()
cursor = connection.cursor()
cursor.execute("INSERT INTO medications (name, quantity, price) VALUES (%s, %s, %s)", (name,
quantity, price))
connection.commit()
cursor.close()
connection.close()
def view_medications():
connection = create_connection()
cursor = connection.cursor()
rows = cursor.fetchall()
cursor.close()
connection.close()
def delete_medication(medication_id):
connection = create_connection()
cursor = connection.cursor()
connection.commit()
cursor.close()
connection.close()
connection = create_connection()
cursor = connection.cursor()
connection.commit()
cursor.close()
connection.close()
def view_stock(medication_id):
connection = create_connection()
cursor = connection.cursor()
result = cursor.fetchone()
cursor.close()
connection.close()
if result:
else:
connection = create_connection()
cursor = connection.cursor()
result = cursor.fetchone()
cursor.close()
connection.close()
if result:
else:
output = (
f"Medication: {name}\n"
print_box(output)
else:
def print_box(message):
print(border)
print(border)
def main():
while True:
print("7. Exit")
if choice == '1':
view_medications()
delete_medication(medication_id)
update_stock(medication_id, quantity)
view_stock(medication_id)
generate_bill(medication_id, quantity)
break
else:
if __name__ == "__main__":
main()