-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreateUsers.py
More file actions
47 lines (42 loc) · 1004 Bytes
/
Copy pathcreateUsers.py
File metadata and controls
47 lines (42 loc) · 1004 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
38
39
40
41
42
43
44
45
46
47
from app import db, models
# u = models.User(nickname='john', email='john@email.com')
# db.session.add(u)
# db.session.commit()
#
# u = models.User(nickname='susan', email='susan@email.com')
# db.session.add(u)
# db.session.commit()
#
# users = models.User.query.all()
# print(users)
# u = models.User.query.get(2)
# print(u)
#
# import datetime
# u = models.User.query.get(1)
# p = models.Post(body='my first post!', timestamp=datetime.datetime.utcnow(), author=u)
# db.session.add(p)
# # db.session.commit()
#
# u = models.User.query.get(1)
# print(u)
#
# posts = u.posts.all()
# print(posts)
#
# for p in posts:
# print(p.id,p.author.nickname,p.body)
#
# u = models.User.query.get(2)
# print(u)
#
# print(u.posts.all())
#
# print(models.User.query.order_by('nickname desc').all())
users = models.User.query.all()
for u in users:
db.session.delete(u)
posts = models.Post.query.all()
for p in posts:
db.session.delete(p)
db.session.commit()