-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathseed_db.py
More file actions
45 lines (40 loc) · 1.24 KB
/
seed_db.py
File metadata and controls
45 lines (40 loc) · 1.24 KB
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
from backend.database import SessionLocal
from backend.models import Product
def seed_menu():
db = SessionLocal()
if db.query(Product).count() > 0:
print("Menu already populated.")
return
products = [
Product(
name="Classic Burger",
description="Juicy beef patty with lettuce and tomato",
price=8.99,
category="Burgers",
image_url="https://via.placeholder.com/150",
modifiers={"size": ["Single", "Double"], "toppings": ["Cheese", "Bacon"]}
),
Product(
name="Cheese Fries",
description="Crispy fries topped with melted cheddar",
price=4.99,
category="Sides",
image_url="https://via.placeholder.com/150",
modifiers={"size": ["Small", "Large"]}
),
Product(
name="Vanilla Shake",
description="Creamy vanilla milkshake",
price=5.99,
category="Drinks",
image_url="https://via.placeholder.com/150",
modifiers={}
)
]
for p in products:
db.add(p)
db.commit()
print("Seeded 3 products.")
db.close()
if __name__ == "__main__":
seed_menu()