def createUser(login_session): newUser = User(name=login_session['username'], email=login_session[ 'email'], picture=login_session['picture']) session.add(newUser) session.commit() user = session.query(User).filter_by(email=login_session['email']).one() return user.id
from sqlalchemy import create_engine from sqlalchemy.orm import sessionmaker from database_setup1 import Country, Destination, Base, User engine = create_engine('sqlite:///traveldestinationswithusers.db') Base.metadata.bind = engine DBSession = sessionmaker(bind=engine) session = DBSession() #create dummy user User1 = User( name="Carson Wentz", email="*****@*****.**", picture= "https://pbs.twimg.com/profile_images/2671170543/18debd694829ed78203a5a36dd364160_400x400.png" ) session.add(User1) session.commit() # destination for Iceland country1 = Country( user_id=1, name="Iceland", image= "https://images.unsplash.com/photo-1439122590297-dde626bb7cf5?auto=format&fit=crop&w=1052&q=60&ixid=dW5zcGxhc2guY29tOzs7Ozs%3D" ) session.add(country1) session.commit()
# 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="huda ", email="*****@*****.**") session.add(User1) session.commit() # list for Face group1 = MakeUp(user_id=1, name="Face") session.add(group1) session.commit() # foundation foundation = MakeUpItem(user_id=1, name="Foundation", group="Face", description="Evens out the skin colour" + ".Usually a liquid, cream, or powder. Of the all " + "the types of makeup,foundation is often the" +
# 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="Shawon Dunston", email="*****@*****.**") session.add(User1) session.commit() # Category for Soccer category1 = Categories(user_id=1, name="Soccer") session.add(category1) session.commit() #items for soccer item1 = Items( user_id=1, title="Nike Pitch Training Soccer Ball", description= """Built for intense training sessions and improving your footwork visibility to predict trajectory with ease.""", categories=category1)