def createUser(login_session): newUser = User(name=login_session['username'], email=login_session['email']) session.add(newUser) session.commit() user = session.query(User).filter_by(email=login_session['email']).one() return user.id
# 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() # Create dummy user User1 = User(name="Robo Barista", email="*****@*****.**", picture='/static/blank_user.gif') session.add(User1) session.commit() # Products for Urban Fruit shop1 = Shop(user_id=1, name="Urban Fruit") session.add(shop1) session.commit() product2 = Product(user_id=1, name="Tofu", description="Tofu", price="$7.50", category="Produce",
from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from catalog_setup import Base, User, Category, Item engine = create_engine('sqlite:///catalogapp.db') Base.metadata.bind = engine DBSession = sessionmaker(bind=engine) session = DBSession() # First User user1 = User(id=1, name="Sean Magrann", email="*****@*****.**") session.add(user1) session.commit() # Categories and Items category1 = Category(name="Dry Flies", image="dryflies.jpg", user=user1) session.add(category1) session.commit() item1 = Item(name="Elk Hair Caddis", description="Most effective Caddis pattern out there!", price="$3.99", picture="elkhair.jpg", category=category1, user=user1) session.add(item1) session.commit() item2 = Item(name="Parachute Adams", description="The most commonly used dry fly ever!", price="$3.99",
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() # Create dummy user User1 = User( name="Robo Barista", email="*****@*****.**", picture= 'https://pbs.twimg.com/profile_images/2671170543/18debd694829ed78203a5a36dd364160_400x400.png' ) session.add(User1) session.commit() # Menu for UrbanBurger catagory1 = Catagory(user_id=1, name="Soccer") session.add(catagory1) session.commit() object2 = Object(user_id=1, name="Shingaurds", description="For protecting your shins", catagory=catagory1)
# 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() # Create dummy user User1 = User(name="Robo Barista", email="*****@*****.**", picture='https://pbs.twimg.com/profile_images.png') session.add(User1) session.commit() # Menu for Soccer category1 = Category(user_id=1, name="Soccer") session.add(category1) session.commit() Item2 = Item( user_id=1, name="Shinguards", description= "A shin guard is a piece of equipment worn on the front of a players shin ", category=category1)
from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from catalog_setup import Base, User, Mall, Items engine = create_engine('sqlite:///catalog.db') Base.metadata.bind = engine DBSession = sessionmaker(bind=engine) session = DBSession() session.commit() # Create a fake user Casneil = User(name="Casneil Simpson", email="*****@*****.**", picture='https://www.facebook.com/photo.php?fbid=391170941\ 236304&set=pb.100010302044120.-2207520000.1561525715\ .&type=3&theater') session.add(Casneil) session.commit() # Making name of the shop Sport Wears with Items # Casneil_Shops = Mall(user_id=1, department="Sport Wears", description="All your Sporting needs!!") session.add(Casneil_Shops) session.commit() Addidas = Items(user_id=1, name="Addidas Sport Max",