0% found this document useful (0 votes)
12 views7 pages

Code 1

This document contains Python source code that defines functions for connecting to a MySQL database, creating tables to store medical store data (accounts, customers, medicines, bills), inserting sample data, retrieving data from tables, and generating bills by retrieving medicine information and customer balances from the tables. The code allows users to log in, view account and medicine information, add customer and medicine records, and generate bills by retrieving relevant data from the different tables.

Uploaded by

opmeayan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views7 pages

Code 1

This document contains Python source code that defines functions for connecting to a MySQL database, creating tables to store medical store data (accounts, customers, medicines, bills), inserting sample data, retrieving data from tables, and generating bills by retrieving medicine information and customer balances from the tables. The code allows users to log in, view account and medicine information, add customer and medicine records, and generate bills by retrieving relevant data from the different tables.

Uploaded by

opmeayan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

SOURCE CODE:

import mysql.connector as sql


conn-sql.connect(host ‘localhost’,user=’root’,
password=’manager’,da tabase=’medical_store’)
if conn.is_connected:
print (successfully connected’)
c1=conn.cursor()
c1.execute(‘create table account_details(User_Name
varchar(30)primary key,password varchar(30) unique)’)
c1.execute(‘create table customers_details(account_number
int primary key,patient_name varchar(30),age int,address
varchar(50),phone_number bigint(11), balance_amount
float)’)
c1.execute(‘create table medicines_details(medicine_name
varchar(30), medicine_code int,gst float,sgst float,total_cost
float)’)
c1.execute(‘create table SS_bill(medicine_name varchar(30),
medicine_code int,gst float,sgst float,cost_per_item
float,quantity int,discount_on_balance_amount
float,total_amount float)’)
print(‘table created’)

import sys
import mysql.connector as sql
conn=sql.connect(host=’localhost’,user=’root’,
password=’manager’,database=’medical_store’)
c1-conn.cursor()
from time import gmtime, strftime
a=strftime(“%a , %d %b %y %H:%M:%S”,gmtime())
if conn.is_connected:
print(“WELCOME TO SS MEDICAL STORE “).
print(a)
print(“1. Login”)
print(“2. Exit”)
print()
option=int(input(“Enter your choise :”))
if option =1:
print()
user=input(‘User Name:’)
user=user.upper()
c1.execute(“select * from account_details where User_Name
like ‘’’ + user + ‘“)
datas=c1.fetchall()
for i in datas:
value_1=i[0]
value_2=i[1]
if user=value_1:
password=input(‘Password :’)
password=password.upper()
if password=value_2:
print()
print(“Login successful’)
print()
print(“11.Customers Account”)
print(“12.Medicine Cost”)
print(“3.Bill”)
print()
option=int(input(“enter a option:”))
if option=11:
account_number=int(input(“enter your acct_number:”))
patient_name=input(“enter your name:”)
age=int(input(“enter your age:”))
address=input(“enter your address:”)
phone_number=int(input(“enter your number:”))
balance_amount=float(input(“enter your amount:”))
x=”insert into customers details
values(“+str(account_number)
+”,”+patient_name+”,”+str(age)+”,”+ad dress+,
+str(phone_number)+”,”+str(balance_amount)+”)”
print(x)
c1.execute(x)
print(“Account created congrats”)
conn.commit()
import mysql.connector as sql
conn=sql.connect(host=localhost’, user=’root’,
password=’manager’,database=’medical_store’)
c1=conn.cursor()
choice=int(input(“enter your choice:”))
if choice=2:
c1.execute(“insert into medicines_details values(‘paracetamal
250mg,325674,1.5,1,5)”)
c1.execute(“insert into medicines_details
values(‘amoxylin’,647890,1,1,4)”)
c1.execute(“insert into medicines_details values(‘zinc
sulphide’,546783,1.5,0.5,3.5)”)
c1.execute(“insert into medicines_details values(‘polodb
500mg,568903,3,2.5,10)”)
c1.execute(“insert into medicines_details values(‘paracetamal
500mg,325679,2,1.5,6)”)
c1.execute(“insert into medicines_details values(‘vicks action
250348,1,0.5,5)”
c1.execute(“insert into medicines_details values(‘dolo
500mg,789541,3,2.5,10)”)
c1.execute(“insert into medicines_details values(‘ferric
Sulphide,546784,1.5,0.5,3.5)”)
print(“Records Created”)
Conn.commit()
if option=3:
print(a)
patient_name=input(“enter the patient_name:”)
no=int(input(‘enter the number of medicine:’))
print(‘customer name:’,patient_name)
for i in range (no):
med_name=input(‘enter medicine name :’)
c1.execute(“select medicine_code , gst , sgst , total_cost from
medicines_details where medicine_name like ‘“ +
str(med_name) + “”)
data =c1.fetchall()
for row in data:
print(‘medicine_code of’, med_name,’:’ ,row[0]
print(‘gst of’ , med_name, ‘:’, row[1])
print(‘sgst of’ , med_name, ‘:’, row[2])
print(‘cost_per_item of,med_name,’:’,row[3])
conn.commit()
account_number=input(‘enter account_number:’)
c1.execute(“select balance_amount from customers_details
where account_number like”+str(account_number)+””)
datas=c1.fetchall()
datas=list(datas[0])
datas=datas[0]
print(datas)
conn.commit()
print(“rows affected:”,c1.rowcount)
conn.commit()
quantity=int(input(“enter the quantity:”))
total_amount=row[3]*quantity
print(“total_amount of”,med_name,’:’,total_amount)
v_sql_insert=”insert into SS_bill
(medicine_name,medicine_code,gst,sgst,cost_per_item,quanti
ty,disc ount_on_balance_amount,total_amount)values(‘{}’,
{},0,0,0,0,0},
{})”.format(med_name,row[0],row[1],row[2],row[3],quantity,
datas ,total_amount)
print(v_sql_insert)
c1.execute(v_sql_insert)
conn.commit()
print(“Records added”)
else:
print(‘Invalid Password’)
print(Tryagain’)
elif option=2:
print(“ THANK YOU VISIT AGAIN “)
sys.exit()

You might also like