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 pathseed.py
More file actions
30 lines (22 loc) · 843 Bytes
/
Copy pathseed.py
File metadata and controls
30 lines (22 loc) · 843 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
#!/usr/bin/env python3
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from models import Base, Company, Dev, Freebie
# Create an engine and session
engine = create_engine('sqlite:///lib/freebies.db')
Session = sessionmaker(bind=engine)
session = Session()
# Create tables
Base.metadata.create_all(engine)
# Create sample companies
company1 = Company(name='TechCorp', founding_year=2000)
company2 = Company(name='InnovateX', founding_year=1995)
# Create sample devs
dev1 = Dev(name='Alice')
dev2 = Dev(name='Bob')
# Create sample freebies
freebie1 = Freebie(item_name='T-Shirt', value=20, company=company1, dev=dev1)
freebie2 = Freebie(item_name='Mug', value=10, company=company2, dev=dev2)
# Add to session and commit
session.add_all([company1, company2, dev1, dev2, freebie1, freebie2])
session.commit()