-
Notifications
You must be signed in to change notification settings - Fork 0
/
Grocery-management.py
141 lines (115 loc) · 4.54 KB
/
Grocery-management.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import mysql.connector as sql
conn = sql.connect(host='localhost', user='root', passwd='manager', database='grocery_shop')
if conn.is_connected():
print('successfully connected')
c = conn.cursor()
print('grocery shop management system')
print('1.login')
print('2.exit')
choice = int(input('enter your choice:'))
if choice == 1:
user_name = input('enter your user name=')
password = input('enter your password=')
while user_name == 'rudra' and password == 'rudra123':
print('connected successfully')
print('grocery shop')
print('1.customer details')
print('2.product details')
print('3.worker details')
print('4.see all customer details')
print('5.see all product details')
print('6.see all worker details')
print('7.see one customer details')
print('8.see one product details')
print('9.see one worker details')
print('10.stocks')
print('11.pie chart for avalibility of stock')
print('12.exit')
choice = int(input('enter the choice'))
if choice == 1:
cust_name = input('enter your name=')
phone_no = int(input('enter your phone number='))
cost = float(input('enter your cost='))
sql_insert = "insert into customer_details values(" + str(phone_no) + ",'" + (cust_name) + "'," + str(
cost) + ")"
c.execute(sql_insert)
conn.commit()
print('data is updated')
elif choice == 2:
product_name = input('enter product name=')
product_cost = float(input('enter the cost='))
sql_insert = "insert into product_details values(""'" + (product_name) + "'," + str(product_cost) + ")"
c.execute(sql_insert)
conn.commit()
print('data is updated')
elif choice == 3:
worker_name = input('enter your name=')
worker_work = input('enter your work=')
worker_age = int(input('enter your age='))
worker_salary = float(input('enter your salary='))
phone_no = int(input('enter your phone number='))
sql_insert = "insert into worker_details values(" "'" + (worker_name) + "'," "'" + (
worker_work) + "'," + str(worker_age) + "," + str(worker_salary) + "," + str(phone_no) + ")"
c.execute(sql_insert)
conn.commit()
print('data is updated')
elif choice == 4:
t = conn.cursor()
t.execute('select*from customer_details')
record = t.fetchall()
for i in record:
print(i)
elif choice == 5:
t = conn.cursor()
t.execute('select*from product_details')
record = t.fetchall()
for i in record:
print(i)
elif choice == 6:
t = conn.cursor()
t.execute('select*from worker_details')
record = t.fetchall()
for i in record:
print(i)
elif choice == 7:
a = input('enter your name')
t = 'select*from customer_details where cust_name=("{}")'.format(a)
c.execute(t)
v = c.fetchall()
for i in v:
print(v)
elif choice == 8:
a = input('enter your product_name')
t = 'select*from product_details where product_name=("{}")'.format(a)
c.execute(t)
v = c.fetchall()
for i in v:
print(v)
elif choice == 9:
a = input('enter your name')
t = 'select*from worker_details where worker_name=("{}")'.format(a)
c.execute(t)
v = c.fetchall()
for i in v:
print(v)
elif choice == 10:
print('******************************************')
f = open('test.txt', 'r')
data = f.read()
print(data)
f.close()
print('******************************************')
elif choice == 11:
import matplotlib.pyplot as plt
items = ('shoes', 'stationary', 'watch', 'house use', 'food items')
avalibility = [156, 200, 103, 206, 196]
colors = ['red', 'yellowgreen', 'blue', 'gold', 'green']
plt.pie(avalibility, labels=items, colors=colors)
plt.title('avalibility of items in shop')
plt.show()
elif choice == 12:
exit()
else:
print('wrong password, try again ')
if choice == 2:
exit()