Has following properties-
Base.metadata.create_all(engine)
#Adding to session
session.add(cc_cookie)
session.commit()
#Accessing attributes
print(cc_cookie.cookie_id)
#This won't work
c1.cookie_id
#Get all cookies together in the form of
#list of cookie objects
cookies = session.query(Cookie).all()
print(cookies)
#Get cookie objects one by one
for cookie in session.query(Cookie):
print(cookie)
#Returns tuple, just returns the first in the list
print(session.query(Cookie.cookie_name, Cookie.quantity).first())
('chocolate chip', 12)
Keep appending functions in the end to generate more complex queries!!
rec_count = session.query(func.count(Cookie.cookie_name)).scalar()
print(rec_count)
Scalar() - Returns first element in the tuple returned
Other Clause Elements -
between(cleft, cright)
in_([list])
is_(None)