-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopulator.py
More file actions
37 lines (31 loc) · 989 Bytes
/
populator.py
File metadata and controls
37 lines (31 loc) · 989 Bytes
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
import models
def populate_test_DB(models):
models.db.connect()
models.db.create_tables(
{
models.Tag,
models.Product,
models.User,
models.BillingInfo,
models.Transaction
}
)
product_data=(
("productname", "bla", 1500, 1, ["tag_name"]),
)
for product_name, description, price, stock, tags in product_data:
product = models.Product.create(
name=product_name,
description=description,
price=price,
stock=stock
)
for tag_name in tags:
tag = models.Tag.create(name="tag_name")
user_data = (
("name", "adress",["product name"]),
)
for name, adress, products in user_data:
user = models.User.create(name=name, adress=adress)
for product in products:
models.Product.create(name=product)