-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__DBInit__.py
60 lines (39 loc) · 1.61 KB
/
__DBInit__.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
import sqlite3
conn = sqlite3.connect('exemple.db')
c = conn.cursor()
##INICIA ESTRUTUR DE DADOS MENU: Contem dados de todos os pratos
c.execute("""CREATE TABLE menu(dish_name varchar unique,
description varchar,
gluten integer,
vegan integer,
vegetarian integer,
lactose integer,
type string,
discount float,
price float)
""")
#exemplos / dados iniciais
c.execute("""INSERT INTO menu VALUES ('pizza','uma pizza hmmm...',1,1,1,1,'principal',50,40)""")
c.execute("""INSERT INTO menu VALUES ('hamburger','uma pizza hmmm...',1,0,0,1,'principal',50,40)""")
##INICIA ESTRUTURA DE DADOS PEDIDO: Contem ID de Pedido e Status
c.execute("""CREATE TABLE restaurantOrder(order_id integer primary key,
tableNo integer,
status varchar
)""")
#exemplos / dados iniciais
c.execute("""INSERT INTO restaurantOrder VALUES (0,1,'solicitado')""")
##INICIA ESTRUTURA DE DADOS PRATOS-PEDIDOS: RELACIONA PRATO COM PEDIDO
c.execute("""CREATE TABLE orderedDishes(
order_id integer REFERENCES restaurantOrder(order_id),
dish_name varchar REFERENCES menu(dish_name),
quantity integer,
halfportion integer,
PRIMARY KEY(order_id,dish_name)
)""")
#exemplos / dados iniciais
c.execute("""INSERT INTO orderedDishes VALUES (0,'pizza',2,0)""")
c.execute("""INSERT INTO orderedDishes VALUES (0,'hamburger',2,1)""")
conn.commit()
conn.close()
#c.execute ("""SELECT * FROM menu""")
#print c.fetchone()