-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlotsOfCatalogs.py
58 lines (48 loc) · 1.3 KB
/
lotsOfCatalogs.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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from database_setup import Catalog, Base, CatalogItem, User
engine = create_engine('sqlite:///catalog.db')
# Bind the engine to the metadata of the Base class so that the
# declaratives can be accessed through a DBSession instance
Base.metadata.bind = engine
DBSession = sessionmaker(bind=engine)
session = DBSession()
# Create filler info
User1 = User(
name="billy",
email="example@gmail.com",
picture='none')
session.add(User1)
session.commit()
catalog1 = Catalog(
user_id=1,
name="Baseball")
session.add(catalog1)
session.commit()
catalogItem = CatalogItem(
user_id=1,
name="Helmet",
description="The Helmet is used to protect the batters head.",
catalog=catalog1)
session.add(catalogItem)
session.commit()
# Create filler info
User2 = User(
name="bob",
email="example@example.com",
picture='none')
session.add(User2)
session.commit()
catalog2 = Catalog(
user_id=2,
name="Football")
session.add(catalog2)
session.commit()
catalogItem2 = CatalogItem(
user_id=2,
name="Football",
description="Cleats are used to provide addational traction on slippery or soft surfaces",
catalog=catalog2)
session.add(catalogItem2)
session.commit()
print "added catalogs and catalog items"