forked from learn-co-curriculum/python-p3-freebie-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug.py
More file actions
38 lines (26 loc) · 962 Bytes
/
debug.py
File metadata and controls
38 lines (26 loc) · 962 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
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from models import Dev, Company, Freebie
engine = create_engine('sqlite:///freebies.db')
Session = sessionmaker(bind=engine)
session = Session()
# View all companies
print("\n--- Companies ---")
for company in session.query(Company).all():
print(company)
# View all devs
print("\n--- Devs ---")
for dev in session.query(Dev).all():
print(dev)
# View all freebies
print("\n--- Freebies ---")
for freebie in session.query(Freebie).all():
print(freebie)
# View freebies belonging to the first company
print("\n--- Freebies by First Company ---")
first_company = session.query(Company).first()
print(f"{first_company.name}'s freebies: {first_company.freebies}")
# View companies associated with the first dev
print("\n--- Companies associated with First Dev ---")
first_dev = session.query(Dev).first()
print(f"{first_dev.name}'s companies: {first_dev.companies}")