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
21 lines (17 loc) · 659 Bytes
/
debug.py
File metadata and controls
21 lines (17 loc) · 659 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#!/usr/bin/env python3
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from models import Company, Dev, Freebie
engine = create_engine('sqlite:///freebies.db')
Session = sessionmaker(bind=engine)
session = Session()
# Try to retrieve the Dev instance with the name "Dev X"
dev = session.query(Dev).filter_by(name="Dev X").first()
if dev:
# If the Dev instance was found, print its freebies
print(f"Freebies collected by {dev.name}:")
for freebie in dev.freebies:
print(freebie.print_details())
else:
# If the Dev instance was not found, display a message
print("Dev X not found in the database.")