-
Notifications
You must be signed in to change notification settings - Fork 0
/
query.py
35 lines (22 loc) · 910 Bytes
/
query.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
"""Test queries"""
from model import db, User, Meetup, Restaurant, Message, Notification, Comment, favorites, user_meetups
import crud
def show_all():
"""Show all users and their restaurant and meetup information."""
# TODO: make these queries more efficient
users = User.query.options(db.joinedload('favorites')).all()
for user in users:
print(user.fname, user.lname)
for rest in user.favorites:
print("- ", rest.name)
print("Hosted Meetups")
for meetup in user.hosted_meetups:
print("*** Host: ", meetup.restaurant)
print("Attending Meetups")
for meetup in user.meetups:
print(" Meetup: ", meetup.restaurant)
print("\n")
if __name__ == '__main__':
from server import app
from model import connect_to_db
connect_to_db(app, echo=False)