-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlotsofcatagories.py
142 lines (94 loc) · 4.09 KB
/
lotsofcatagories.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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from database_setup import Categories, Items, Users, Base, Recent
from datetime import datetime
engine = create_engine('sqlite:///catalogdb.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)
# A DBSession() instance establishes all conversations with the database
# and represents a "staging zone" for all the objects loaded into the
# database session object. Any change made against the objects in the
# session won't be persisted into the database until you call
# session.commit(). If you're not happy about the changes, you can
# revert all of them back to the last commit by calling
# session.rollback()
session = DBSession()
users = Users(name="Sina Serati", email="[email protected]")
session.add(users)
session.commit()
users2 = Users(name="fake name", email="[email protected]")
session.add(users)
session.commit()
cat1 = Categories(name="Soccer")
session.add(cat1)
session.commit()
item1 = Items(title="Shoes", description="Football boots, called cleats or soccer shoes in North America, are an item of footwear worn when playing football. Those designed for grass pitches have studs on the outsole to aid grip.",
user=users, category=cat1)
session.add(item1)
session.commit()
recent1 = Recent(created_date=datetime.now(),item=item1)
session.add(recent1)
session.commit()
item2 = Items(title="Gloves", description="While only one player on the field is wearing them, goalkeeper gloves are an essential part of every soccer team's defense. Goalkeeper gloves provide a better grip on the ball, protect and cushion your fingers and palms, and help you block, catch and punch the ball.",
user=users, category=cat1)
session.add(item2)
session.commit()
recent1 = Recent(created_date=datetime.now(),item=item2)
session.add(recent1)
session.commit()
item3 = Items(title="Yellow Card", description="Every good soccer play should earn one, at least once a game.",
user=users2, category=cat1)
session.add(item3)
session.commit()
recent1 = Recent(created_date=datetime.now(),item=item3)
session.add(recent1)
session.commit()
#--------------------
cat2 = Categories(name="Basketball")
session.add(cat2)
session.commit()
item1 = Items(title="Shoes", description="The insert is a feature that appears on some basketball shoe models. It is a detachable insole designed to provide arch support.",
user=users, category=cat2)
session.add(item1)
session.commit()
recent1 = Recent(created_date=datetime.now(),item=item1)
session.add(recent1)
session.commit()
item2 = Items(title="ball", description="hard, round and orange.",
user=users, category=cat2)
session.add(item2)
session.commit()
recent1 = Recent(created_date=datetime.now(),item=item2)
session.add(recent1)
session.commit()
#------------------------
cat3 = Categories(name="Hockey")
session.add(cat3)
session.commit()
item1 = Items(title="puck", description="hard, round and flat at the same time. Small too.",
user=users, category=cat3)
session.add(item1)
session.commit()
recent1 = Recent(created_date=datetime.now(),item=item1)
session.add(recent1)
session.commit()
#------------------------
cat4 = Categories(name="Skating")
session.add(cat4)
session.commit()
item1 = Items(title="trucks", description="used for turning, you want time modiretly tight, depending on your driving condition",
user=users, category=cat4)
session.add(item1)
session.commit()
recent1 = Recent(created_date=datetime.now(),item=item1)
session.add(recent1)
session.commit()
item2 = Items(title="grip tape", description="Grip tape is the gritty, sand papery layer that's applied to the top of a skateboard deck so that your shoes can grip the board. Skaters often cut patterns into their grip tape before applying it.",
user=users, category=cat4)
session.add(item2)
session.commit()
recent1 = Recent(created_date=datetime.now(),item=item2)
session.add(recent1)
session.commit()