-
Notifications
You must be signed in to change notification settings - Fork 0
/
kitchen_main.py
64 lines (54 loc) · 1.52 KB
/
kitchen_main.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
import sqlite3
conn = sqlite3.connect("login_db.db")
def db_retrieve(all=False):
menu = [
"biryani",
"dosa",
"drink",
"french",
"fried",
"idli",
"noodles",
]
main_query=""
if all:
main_query = "SELECT * FROM orders"
else:
main_query = "SELECT * FROM orders WHERE delivered=0"
return_dict = {}
retrieved_info = []
list_var = conn.execute(main_query)
rows = list(list_var.fetchall())
for row in rows:
temp_list = []
id = row[0]
for item in menu:
condition = "company_name" if item=="drink" else item+"_type"
query = f"SELECT * FROM {item} WHERE order_no={id} AND {condition}!='Null';"
items = conn.execute(query)
for item in items:
if item[2]!=0:
temp_list.append(item)
retrieved_info.append(temp_list)
temp_list = []
for items in retrieved_info:
temp_list, id = [], 0
for item in items:
if item:
temp_list.append((item[1], item[2]))
id = item[0]
return_dict[id] = temp_list
temp_list = []
id = 0
return return_dict
def order_ids(all=False):
query=""
if all:
query = "SELECT order_no FROM orders"
else:
query = "SELECT order_no FROM orders WHERE delivered=0"
return_id = []
ids = conn.execute(query)
for id in ids:
return_id.append(id[0])
return return_id