forked from jeffknupp/bull
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpopulate_db.py
More file actions
62 lines (54 loc) · 1.33 KB
/
populate_db.py
File metadata and controls
62 lines (54 loc) · 1.33 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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
import uuid
from bull import app
app.config['STRIPE_SECRET_KEY'] = None
from bull.models import Product, Purchase, db
pdf2 = Product(
id=1,
name='Writing Idiomatic Python 2.7 PDF',
file_name='writing_idiomatic_python_2.pdf',
version='1.5',
is_active=True,
price=9.99)
pdf3 = Product(
id=2,
name='Writing Idiomatic Python 3 PDF',
file_name='writing_idiomatic_python_3.pdf',
version='1.5',
is_active=True,
price=9.99)
epub2 = Product(
id=3,
name='Writing Idiomatic Python 2.7 ePub',
file_name='writing_idiomatic_python_2.epub',
version='1.5',
is_active=True,
price=9.99)
epub3 = Product(
id=4,
name='Writing Idiomatic Python 2.7 ePub',
file_name='writing_idiomatic_python_3.epub',
version='1.5',
is_active=True,
price=9.99)
bundle = Product(
id=5,
name='Writing Idiomatic Python Bundle',
file_name='writing_idiomatic_python.zip',
version='1.5',
is_active=True,
price=14.99)
purchase = Purchase(
uuid=str(uuid.uuid4()),
product_id=pdf3.id,
)
with app.app_context():
session = db.session()
db.metadata.create_all(db.engine)
session.add(pdf2)
session.add(pdf3)
session.add(epub2)
session.add(epub3)
session.add(bundle)
session.add(purchase)
session.commit()