-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup_and_seed.py
43 lines (39 loc) · 1.22 KB
/
setup_and_seed.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
from techtest.models import *
from techtest.models.article import Article
from techtest.models.region import Region
from techtest.models.author import Author
from techtest.connector import engine, BaseModel, db_session
BaseModel.metadata.create_all(engine)
with db_session() as session:
au = Region(code="AU", name="Australia")
uk = Region(code="UK", name="United Kingdom")
us = Region(code="US", name="United States of America")
author1 = Author(first_name="Ben", last_name="Tyron")
author2 = Author(first_name="Hughes", last_name="Jeff")
author3 = Author(first_name="Louis", last_name="Jamie")
session.add_all([
au,
uk,
us,
author1,
author2,
author3,
Article(
title='Post 1',
content='This is a post body',
regions=[au, uk],
authors=[author1, author2],
),
Article(
title='Post 2',
content='This is the second post body',
regions=[au, us],
authors=[author2, author3]
),
Article(
title='Post 3',
content='This is the third post body',
regions=[au, uk],
authors=[author1]
),
])