Beispiel #1
0
# 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  user
User1 = User(name="latifa", email="*****@*****.**")
session.add(User1)
session.commit()

# Item for Action movies
category1 = Category(user_id=1, name="Action")

session.add(category1)
session.commit()

Item1 = Item(
    user_id=1,
    title="Mission Impossible Fallout",
    description=
    "Ethan Hunt and his IMF team along with some familiar allies race against time after a mission gone wrong",  # noqa
    category=category1)

session.add(Item1)
session.commit()

Item2 = Item(
# 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()

Daniel = User(name="Daniel Burkard")
session.add(Daniel)

John = User(name="John Doe")
session.add(John)

Basketball = Category(name="Basketball")
session.add(Basketball)

Baselball = Category(name="Baselball")
session.add(Baselball)

Snowboarding = Category(name="Snowboarding")
session.add(Snowboarding)

Judo = Category(name="Judo")
session.add(Judo)

Capoeira = Category(name="Capoeira")
session.add(Capoeira)

IceHockey = Category(name="Ice Hockey")
Beispiel #3
0
# 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 user
User1 = User(name="Ghada", email="*****@*****.**")
session.add(User1)
session.commit()


# Book Category #1
category1 = Category(user_id=1, name="Fiction")

session.add(category1)
session.commit()

BookItem1 = Item(user_id=1, title="Kafka on the Shore", author="Haruki Murakami", category=category1)

session.add(BookItem1)
session.commit()

BookItem2 = Item(user_id=1, title="Sharp Objects", author="Gillian Flynn", category=category1)

session.add(BookItem2)
session.commit()

BookItem3 = Item(user_id=1, title="The Girl on the Train", author="Paula Hawkins", category=category1)
Beispiel #4
0
# Base.metadata.bind(engine)

DBSession = sessionmaker(bind=engine)
session = DBSession()

#Create user
user1 = User(
    name="Diane Van Etten",
    email="*****@*****.**",
    picture="https://www.pexels.com/photo/yellow-flowers-on-brown-sand-1167465/"
)
session.add(user1)
session.commit()

#Create categories
category1 = Category(name="Router")
session.add(category1)
session.commit()

#Create items for temp category 1
item1 = Item(
    name="UniFi Security Gateway",
    user_id=1,
    description=
    "The UniFi security gateway extends the UniFi Enterprise System to provide cost-effective, reliable routing and advanced security for your network.",
    category=category1)
session.add(item1)
session.commit()

item2 = Item(name="UniFi Security Gateway Pro $",
             user_id=1,
)
session.add(User1)
session.commit()

# Create dummy user
User2 = User(
    name="Terry Rossi",
    email="*****@*****.**",
    picture=
    'https://pbs.twimg.com/profile_images/2671170543/18debd694829ed78203a5a36dd364160_400x400.png'
)
session.add(User2)
session.commit()

#Menu for Food
category1 = Category(user_id=2, name="Food")

session.add(category1)
session.commit()

product1 = Product(
    user_id=2,
    name="Veggie Burger",
    description="Juicy grilled veggie patty with tomato mayo and lettuce",
    price="$7.50",
    category=category1)

session.add(product1)
session.commit()

product2 = Product(
Beispiel #6
0
def add_category(category_name):
    """Add category to DB."""
    new_category = Category(name=category_name)
    session.add(new_category)
    session.commit()
    return
Beispiel #7
0
# 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()

# add categories
myFirstCategory = Category(name='New York')
session.add(myFirstCategory)
session.commit()

mySecondCategory = Category(name='Chicago')
session.add(mySecondCategory)
session.commit()

myThirdCategory = Category(name='Los Angeles')
session.add(myThirdCategory)
session.commit()

myFourthCategory = Category(name='Dallas')
session.add(myFourthCategory)
session.commit()
Beispiel #8
0
}

#Hockey Items
# Retreived from: https://en.wikipedia.org/wiki/Ice_hockey_equipment
hockey_items = {
    'Helmet':
    'A helmet with strap, and optionally a face cage or visor, is required of all ice hockey players.',
    'Neck guard':
    'For "skaters", a neck guard typically consists of a series of nylon or ABS plates for puncture resistance.',
    'Shoulder pads':
    'Hockey shoulder pads are typically composed of a passed vest with front and back panels.'
}

#Adding Categories and items to DB
for cat in categories:
    category_name = Category(name=cat)
    session.add(category_name)
    session.commit()
    if cat == "Soccer":
        for soccerItem in soccer_items:
            item = Items(user_id=1,
                         name=soccerItem,
                         description=soccer_items[soccerItem],
                         category=category_name)
            session.add(item)
            session.commit()
    elif cat == "Basketball":
        for basketballItem in basketball_items:
            item = Items(user_id=1,
                         name=basketballItem,
                         description=basketball_items[basketballItem],
Beispiel #9
0
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()

#Categories are Tech, Style, Outdoors, Household, Dude I Want That!,

#Items for Tech
category1 = Category(name="Tech")

session.add(category1)
session.commit()

catalogItem1 = CatalogItem(
    name="goTenna",
    description=
    "Whether you're skiing or camping you know how annoying it can be to get ahold of your friends. The goTenna solves messaging this by sending messages without cell service.",
    price="$149.00",
    category=category1)

session.add(catalogItem1)
session.commit()

catalogItem2 = CatalogItem(
# 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()

# Items for Football
category1 = Category(name="Football")

session.add(category1)
session.commit()

item1 = Item(title="Football",
             description="A black and white ball",
             category=category1,
             picture='football.jpg')

session.add(item1)
session.commit()

# Items for Cricket
category2 = Category(name="Cricket")
Beispiel #11
0
from sqlalchemy.orm import sessionmaker

from database_setup import Category, Base, User, Item

engine = create_engine('postgresql://*****:*****@localhost:5432/catalogdb')

Base.metadata.bind = engine

DBSession = sessionmaker(bind=engine)

session = DBSession()


user1 = User(name='Aditya', email='*****@*****.**', picture='')

category1 = Category(name='Voice Assistants', user_id=user1.id)

session.add(category1)
session.commit()

item1 = Item(name='Google Home',
             description='Google Assistant with voice powered smart home device',  # NOQA
             image='https://lh3.googleusercontent.com/igThvoKwToXtZOfTANWbgp2ZoLnPBV2KDt9oJuaK419yIHQIo24eIcsCbgWcnfwlFjs=w1000',  # NOQA
             category=category1,
             user_id=user1.id)

session.add(item1)
session.commit()

item2 = Item(name='Google Home Mini',
             description='Google Assistant with voice powered smart home device',  # NOQA
Beispiel #12
0
# 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()


# Category for Fishing
category1 = Category(user_id=1, name="Fishing")

session.add(category1)
session.commit()

print 'category name = ' + category1.name



Item1 = Item(user_id=1,
             name="Zebco Pole",
             description="Crappie Pole. Light weight for some Live Action.  Great companion in the Spring time when calling in sick to work.",
             category_name=category1.name)

session.add(Item1)
session.commit()
from database_setup import Base, User, Category, Item

engine = create_engine('sqlite:///catalog.db')
Base.metadata.bind = engine

DBSession = sessionmaker(bind=engine)
session = DBSession()

# Create Admin user
Admin = User(id=1, name="Admin", email="*****@*****.**")
session.add(Admin)
session.commit()

# Category: Laptop accessories
category1 = Category(id=1, name="Laptop accessories")

session.add(category1)
session.commit()

Item1 = Item(title="Darth Vader 15 inches cover",
             description="A nice Darth Vader black finish cover for your 15\
                         inches laptop.",
             cat_id=1,
             user_id=1)

session.add(Item1)
session.commit()

Item2 = Item(title="R2D2 Macbook Pro 13 inches cover",
             description="Make your Macbook Pro 13 inches prettier with\
Beispiel #14
0
# 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()

# Items for Category 1
category1 = Category(name="Category 1", user_id=1)

session.add(category1)
session.commit()

category_item1 = CategoryItem(
    name="Item 1",
    description=
    "Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.",
    created_date=func.current_timestamp(),
    category_id=1,
    user_id=1)

session.add(category_item1)
session.commit()
Beispiel #15
0
DBSession = sessionmaker(bind=engine)

session = DBSession()

# Create dummy user
user1 = User(
    name="dummy",
    email="*****@*****.**",
    picture=
    "https://pbs.twimg.com/profile_images/2671170543/18debd694829ed78203a5a36dd364160_400x400.png"
)
session.add(user1)
session.commit()
# Create dummy categories
category1 = Category(name="Football")
session.add(category1)
session.commit()

category2 = Category(name="Tennis")
session.add(category2)
session.commit()

category3 = Category(name="Handball")
session.add(category3)
session.commit()

category4 = Category(name="Basketball")
session.add(category4)
session.commit()
Beispiel #16
0
# revert all of them back to the last commit by calling
# session.rollback()
session = DBSession()

# Create dummy user
User1 = User(
    name="Mohamed Ismail",
    email="*****@*****.**",
    picture=
    'https://pbs.twimg.com/profile_images/2671170543/18debd694829ed78203a5a36dd364160_400x400.png'
)
session.add(User1)
session.commit()

# Menu for Air sports
category1 = Category(user_id=1, name="AirSports")

session.add(category1)
session.commit()

menuItem1 = MenuItem(
    user_id=1,
    title="Aerobatics",
    description=
    "Aerobatics are performed in airplanes and gliders for training, recreation, entertainment, and sport.",
    category=category1)

session.add(menuItem1)
session.commit()

menuItem2 = MenuItem(
Beispiel #17
0
# session.rollback()
session = DBSession()

# Create dummy user
User = User(
    name="Hadi Ramezani",
    email="*****@*****.**",
    id=1,
    picture=
    'https://pbs.twimg.com/profile_images/2671170543/18debd694829ed78203a5a36dd364160_400x400.png'
)
session.add(User)
session.commit()

# Items for Computers and Accessories
category = Category(id=1, name="Computers and Accessories", user_id=1)

session.add(category)
session.commit()

category_item = CategoryItem(
    user_id=1,
    name="Laptop",
    description=
    "A laptop, also called a notebook computer or simply a notebook, is a small, "
    "portable personal computer with a 'clamshell' form factor, having, typically,"
    " a thin LCD or LED computer screen mounted on the inside of the upper lid of "
    "the 'clamshell' and an alphanumeric keyboard on the inside of the lower lid. "
    "The 'clamshell' is opened up to use the computer. Laptops are folded shut for"
    " transportation, and thus are suitable for mobile use. Its name comes from "
    "'lap', as it was deemed to be placed for use on a person's lap. Although "
Beispiel #18
0
Base.metadata.bind = engine
DBSession = sessionmaker(bind=engine)
session = DBSession()

# Delete all the categories to avoid repetition
session.query(Category).delete()
session.commit()

# Delete all the items to avoid repetition
session.query(Item).delete()
session.commit()

# Start new entries

# Creating a new Category
category1 = Category(name="Cricket")
session.add(category1)
session.commit()

# Creating an item in the category
item1 = Item(name="Bat", description="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce eget ligula convallis, pellentesque tortor id, aliquet dui. Vestibulum vulputate ultricies nisi. Vivamus fringilla lacinia sodales.",
                     price="$7.50", size="Large", category=category1)
session.add(item1)
session.commit()

item1 = Item(name="Ball", description="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce eget ligula convallis, pellentesque tortor id, aliquet dui. Vestibulum vulputate ultricies nisi. Vivamus fringilla lacinia sodales.",
                     price="$7.50", size="Large", category=category1)
session.add(item1)
session.commit()

item2 = Item(name="Batting Gloves", description="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Fusce eget ligula convallis, pellentesque tortor id, aliquet dui. Vestibulum vulputate ultricies nisi. Vivamus fringilla lacinia sodales.",
# revert all of them back to the last commit by calling
# session.rollback()
session = DBSession()

#Dummy User
User1 = User(
    name="Administrator",
    email="*****@*****.**",
    picture=
    'https://pbs.twimg.com/profile_images/2671170543/18debd694829ed78203a5a36dd364160_400x400.png'
)
session.add(User1)
session.commit()

#Menu for UrbanBurger
category1 = Category(user_id=1, name="soccer")

session.add(category1)
session.commit()

item1 = Item(user_id=1,
             title="Boots",
             description="Durable footware",
             category=category1)

session.add(item1)
session.commit()

item2 = Item(user_id=1,
             title="Gloves",
             description="Goalkeeping",
# 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="Sudhanshu Tiwari",
    email="*****@*****.**",
    picture='/assests/image-profile.jpg')
session.add(user1)
session.commit()

# Items for Strings
category1 = Category(name="Arts & Photography", user_id=1)

session.add(category1)
session.commit()

item1 = CategoryItem(
    name="The 5 Love Languages: The Secret to Love that Lasts",
    user_id=1,
    description="In the no.1 New York Times bestseller The 5 Love Languages,"
    "you will discover the secret that has transformed millions of relationships"
    "worldwide. Whether your relationship is flourishing or failing, Dr. Gary "
    "Chapmans proven approach to showing and receiving love will help you "
    "experience deeper and richer level of intimacy with your partner starting"
    "today.The 5 Love Languages is as practical as it is insightful."
    "Updated to reflect"
    "the complexities of relationships today, this new edition "
Beispiel #21
0
# 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="Ahmed Sayed Ahmed", email="*****@*****.**",
             picture='http://all-best.co/wp-content/'
             'uploads/2017/08/unnamed-file-231.jpg')
session.add(User1)
session.commit()

# Menu for UrbanBurger
category1 = Category(user_id=1, name="Urban Burger")

session.add(category1)
session.commit()


Item1 = Item(user_id=1, name="French Fries",
             description="with garlic and parmesan",
             price="$2.99", created="Entree", category=category1)

session.add(Item1)
session.commit()

Item2 = Item(user_id=1, name="Chicken Burger",
             description="Juicy grilled chicken",
             price="$5.50", created="Entree", category=category1)
Beispiel #22
0
    DBSession = sessionmaker(bind=engine)
    session = DBSession()

    # Create some data
    has_data = session.query(Category).all()
    if not has_data:
        print("Creating some data...")

        item1 = Item(name='Cool Shirt',
                     description='Just a cool shirt.',
                     owner_mail='*****@*****.**')
        item2 = Item(name='Really Cool Shirt',
                     description='A realy cool shirt.',
                     owner_mail='*****@*****.**')

        c1 = Category(name='Clothes', items=[item1, item2])
        session.add(c1)

        item3 = Item(name='Star Wars Battlefront II',
                     description='An epic game from the Star Wars saga.',
                     owner_mail='*****@*****.**')
        item4 = Item(name='FIFA 19',
                     description='Play with the bests!',
                     owner_mail='*****@*****.**')
        c2 = Category(name='Games',
                      date_created=datetime.now() + timedelta(seconds=60),
                      items=[item3, item4])
        session.add(c2)

        item5 = Item(name='Star Wars III',
                     description='The best movie on the Star Wars saga.',
# Connect the engine to a session
Session = sessionmaker(bind=engine)

# Setting up a Session object
session = Session()

user1 = User(
    name='Abdulrahman',
    email='*****@*****.**',
)

session.add(user1)
session.commit()

category3 = Category(name='test category3', user=user1)

session.add(category3)
session.commit()

item3 = Item(name='Item 3 test',
             description='It is an test item. to test the app',
             category=category3,
             user=user1)

session.add(item3)
session.commit()

category4 = Category(name='test category4', user=user1)

session.add(category4)
# 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="Selim Felex", email="*****@*****.**", picture='')
session.add(User1)
session.commit()

# Menu for UrbanBurger
category1 = Category(user_id=1, name="Networks")

session.add(category1)
session.commit()

category2 = Category(user_id=1, name="Laptops")

session.add(category2)
session.commit()

category3 = Category(user_id=1, name="Computers")

session.add(category3)
session.commit()

catITem1 = Item(
engine = create_engine('sqlite:///catalog.db')

Base.metadata.bind = engine

DBSession = sessionmaker(bind=engine)

session = DBSession()

# Create dummy user
User1 = User(name="Ali Khaled", email="*****@*****.**")
session.add(User1)
session.commit()

# Items for Mammal
category1 = Category(user_id=1, name="Mammal")

session.add(category1)
session.commit()

# First item in mammals
Item1 = Item(user_id=1,
             name="Bats",
             description=("bats are very special mammals.They are the only"
                          "mammals that can fly (without an airplane!)"
                          "Flying squirrels are mammals too, but they"
                          "don't really fly  They jump from high in a"
                          "tree glide through the air like a kite."
                          "Bats flap their wings and fly like a bird."),
             category=category1)
Beispiel #26
0
# 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()

# Ironman Category
category1 = Category(name="Ironman")
session.add(category1)
session.commit()

# Ironman 70.3 Category
category2 = Category(name="Ironman 70.3")
session.add(category2)
session.commit()

# Spartan Category
category3 = Category(name="Spartan")
session.add(category3)
session.commit()

# RocknRoll Category
category4 = Category(name="RocknRoll")
# 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()

#Menu for UrbanBurger
category = Category(name="Soccer")
session.add(category)
session.commit()

category2 = Category(name="Basketball")
session.add(category2)
session.commit()

category3 = Category(name="Baseball")
session.add(category3)
session.commit()

item = Item(
    name="Veggie Burger",
    description="Juicy grilled veggie patty with tomato mayo and lettuce",
    sub="1",
Beispiel #28
0
# 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="Chris Rectenwald", email="*****@*****.**")
session.add(User1)
session.commit()

# Items for FinTech stocks
category1 = Category(name="FinTech Stocks", user_id=User1.id)

session.add(category1)
session.commit()

# Item for FinTech Stocks
item1 = Item(name="JPMorgan Chase",
             description="""
            Jamie Dimon's Kingdom 
             """,
             category_id=category1.id,
             user_id=User1.id)
session.add(item1)
session.commit()

item2 = Item(
Beispiel #29
0
# Create session object
DBSession = sessionmaker(bind=engine)
session = DBSession()

# Add data to database

User1 = User(name="Lujain Sul", email="*****@*****.**")
session.add(User1)
session.commit()

User2 = User(name="Lujain Ghul", email="*****@*****.**")
session.add(User2)
session.commit()

# Category for Soccer
category1 = Category(name="Soccer")
session.add(category1)
session.commit()

category1_item1 = Item(title="Soccer Cleats",
                       description="The shoes",
                       addition_dt=datetime.datetime(2018, 11, 1, 1, 0),
                       user=User1,
                       category=category1)
session.add(category1_item1)
session.commit()

category1_item2 = Item(title="Jersey",
                       description="The shirt",
                       addition_dt=datetime.datetime(2018, 11, 2, 10, 0),
                       user=User1,
Beispiel #30
0
# 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()

#User
user1 = User(name="Olivia Gmail",email="*****@*****.**")
session.add(user1)
session.commit()

user2 = User(name="Olivia Facebook",email="*****@*****.**")
session.add(user2)
session.commit() 

#Category
category1 = Category(name="Soccer")
session.add(category1)
session.commit()

category2 = Category(name="Basketball")
session.add(category1)
session.commit()

category3 = Category(name="Snowboarding")
session.add(category1)
session.commit()

dateTimeNow = datetime.datetime.now()

#Menu for UrbanBurger
item1 = Item(name = "Soccer Ball", description="an inflated ball used in playing soccer",