-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseeds.py
57 lines (50 loc) · 2.1 KB
/
seeds.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
from app.models import User, Post, Comment, Vote
from app.db import Session, Base, engine
# drop and rebuild tables
Base.metadata.drop_all(engine)
Base.metadata.create_all(engine)
db = Session()
# insert users
db.add_all([
User(username='tester', email='test@test.com', password='testtest'),
User(username='jwilloughway1',
email='rmebes1@sogou.com', password='password123'),
User(username='iboddam2', email='cstoneman2@last.fm', password='password123'),
User(username='dstanmer3', email='ihellier3@goo.ne.jp', password='password123'),
User(username='djiri4', email='gmidgley4@weather.com', password='password123'),
])
db.commit()
# insert posts
db.add_all([
Post(title='Donec posuere metus vitae ipsum',
post_url='https://buzzfeed.com/in/imperdiet/et/commodo/vulputate.png', user_id=1),
Post(title='Morbi non quam nec dui luctus rutrum',
post_url='https://nasa.gov/donec.json', user_id=1),
Post(title='Donec diam neque, vestibulum eget, vulputate ut, ultrices vel, augue',
post_url='https://europa.eu/parturient/montes/nascetur/ridiculus/mus/etiam/vel.aspx', user_id=2),
Post(title='Nunc purus', post_url='http://desdev.cn/enim/blandit/mi.jpg', user_id=3),
Post(title='Pellentesque eget nunc',
post_url='http://google.ca/nam/nulla/integer.aspx', user_id=4)
])
db.commit()
# insert comments
db.add_all([
Comment(comment_text='Nunc rhoncus dui vel sem.', user_id=1, post_id=2),
Comment(comment_text='Morbi odio odio, elementum eu, interdum eu, tincidunt in, leo. Maecenas pulvinar lobortis est.', user_id=1, post_id=3),
Comment(comment_text='Aliquam erat volutpat. In congue.',
user_id=2, post_id=1),
Comment(comment_text='Quisque arcu libero, rutrum ac, lobortis vel, dapibus at, diam.',
user_id=2, post_id=3),
Comment(comment_text='In hac habitasse platea dictumst.', user_id=3, post_id=3)
])
db.commit()
# insert votes
db.add_all([
Vote(user_id=1, post_id=2),
Vote(user_id=1, post_id=4),
Vote(user_id=2, post_id=4),
Vote(user_id=3, post_id=4),
Vote(user_id=4, post_id=2)
])
db.commit()
db.close()