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
43 lines (28 loc) · 1.15 KB
/
debug.py
File metadata and controls
43 lines (28 loc) · 1.15 KB
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
#!/usr/bin/env python3
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from models import Company, Dev, Freebie , Base
# Create an SQLite database engine and initialize the database
engine = create_engine('sqlite:///freebies.db')
Base.metadata.create_all(engine)
# Create a session to interact with the database
Session = sessionmaker(bind=engine)
session = Session()
if __name__ == '__main__':
import ipdb; ipdb.set_trace()
company1= Company(name = "Scinov", founding_year = 2015)
company2= Company(name = "Taisa", founding_year = 2021)
dev1= Dev(name= "Faith")
dev2= Dev(name= "Nyolei")
session.add_all([company1, company2, dev1, dev2])
session.commit()
# Assign freebies to developers from specific companies
company1.give_freebie(dev1, "Laptop", 1)
company1.give_freebie(dev2, "smartphone", 2)
company2.give_freebie(dev1, "notebook", 3)
company2.give_freebie(dev2, "Headphones", 4)
freebies = session.query(Freebie).all()
for freebie in freebies:
print(freebie.print_details())
print(dev1.received_one("Laptop"))
print(dev1.received_one("smart watch"))