Exemple #1
0
def syncdb():
    from catalog import db, models, create
    create(CONFIG)
    db.create_all()
 * Project: catalog
 * Author name: Iraquitan Cordeiro Filho
 * Author login: pma007
 * File: populate_db
 * Date: 2/29/16
 * Time: 17:47
 * To change this template use File | Settings | File Templates.
"""
import os

from catalog import db
from catalog.models import User, Category, Item

# Create database if not exist
if not os.path.exists("./catalog/catalog.db"):
    db.create_all()

# Add User
user = User(name="Robo Barista", email="*****@*****.**",
            password="******", picture="https://pbs.twimg.com/profile_images/2671170543/18debd694829ed78203a5a36dd364160_400x400.png")  # noqa
db.session.add(user)
db.session.commit()

# Add Categories
categories = ['Soccer', 'Basketball', 'Baseball', 'Frisbee', 'Snowboarding',
              'Rock Climbing', 'Foosball', 'Skating', 'Hockey']
for category in categories:
    new_category = Category(name=category, user_id=1)
    db.session.add(new_category)
    db.session.commit()
Exemple #3
0
 def setUp(self):
     self.app = create_app('application.testing.cfg')
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()
def main():
    #drop the database tables
    #create the database and the tables
    db.drop_all()
    db.create_all()
        # Create stock, out of the box user
    UserArtV = User(name="Art Vandalay",
                    email="*****@*****.**",
                    picture="/static/costanza.jpg")
    db.session.add(UserArtV)
    db.session.commit()

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

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

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

    category4 = Category(name="Frisbee")
    db.session.add(category4)
    db.session.commit()

    category5 = Category(name="Snowboarding")
    db.session.add(category5)
    db.session.commit()

    category6 = Category(name="Rock Climbing")
    db.session.add(category6)
    db.session.commit()

    category7 = Category(name="Foosball")
    db.session.add(category7)
    db.session.commit()

    category8 = Category(name="Skating")
    db.session.add(category8)
    db.session.commit()

    category9 = Category(name="Hockey")
    db.session.add(category9)
    db.session.commit()

    item1 = Item(user_id=1, name="Stick", description="Interdum odio dignissim in nisi metus\
                 , a elit sit dis cubilia, fringilla praesent pulvinar porta.\
                 Sodales hac bibendum", category=category9)
    db.session.add(item1)
    db.session.commit()

    item2 = Item(user_id=1, name="Goggles",
                 description="Primis dignissim mattis erat bibendum eu arcu quis\
                  cursus", category=category5)
    db.session.add(item2)
    db.session.commit()

    item3 = Item(user_id=1, name="Snowboard",
                 description="Curae feugiat netus auctor lacus",
                 category=category5)
    db.session.add(item3)
    db.session.commit()

    item4 = Item(user_id=1, name="Soccer Item 1", description="Nec odio consectetur cum \
                 consequat quam massa habitant placerat, nam tincidunt mi egestas \
                 eu taciti velit dictum aenean, vestibulum inceptos semper \
                 penatibus proin fringilla quisque. Cursus ridiculus facilisis \
                 class erat varius cum consequat, ac at justo mattis magna dui \
                 suscipit interdum, faucibus auctor rhoncus diam parturient a.",
                 category=category1)
    db.session.add(item4)
    db.session.commit()

    item5 = Item(user_id=1, name="Soccer Item 2", description="Fermentum scelerisque \
                 facilisis tortor rhoncus magna maecenas, blandit ligula metus \
                 amet congue fames pulvinar, eget aliquam augue eros per. Vel \
                 etiam dolor ornare aliquet posuere inceptos maecenas nam, varius \
                 eget ad imperdiet mi phasellus turpis nisl libero, urna \
                 tristique aptent ultricies taciti montes parturient.",
                 category=category1)
    db.session.add(item5)
    db.session.commit()

    item6 = Item(user_id=1, name="Soccer Item 3", description="Placerat primis taciti etiam \
                 ut convallis accumsan lorem tortor sapien faucibus cursus, quam \
                 nulla tempor morbi rhoncus suscipit sociis in litora amet enim, \
                 praesent aptent bibendum integer ornare dapibus justo rutrum \
                 aliquet vivamus. Taciti dignissim neque euismod elit maecenas \
                 aptent interdum mollis vel sociosqu donec, nunc gravida eget ad \
                 quisque viverra vitae amet hendrerit.", category=category1)
    db.session.add(item6)
    db.session.commit()

    item7 = Item(user_id=1, name="Soccer Item 4", description="Litora turpis et dignissim \
                 nascetur faucibus taciti vivamus interdum, tempor dapibus lorem \
                 venenatis enim conubia lacus netus hac, dis magnis vel nulla \
                 phasellus bibendum fringilla. Sed torquent taciti accumsan elit \
                 sagittis nulla magnis, sit praesent volutpat nam consectetur \
                 velit, magna sociis id ultrices diam non.", category=category1)
    db.session.add(item7)
    db.session.commit()

    item8 = Item(user_id=1, name="Frisbee", description="Interdum odio dignissim in nisi \
                 metus, a elit sit dis cubilia, fringilla praesent pulvinar \
                 porta. Sodales hac bibendum tincidunt risus mus himenaeos erat \
                 ac, mollis semper integer tempor lacus turpis libero, ridiculus \
                 primis curae aliquet nec rhoncus ante.", category=category4)
    db.session.add(item8)
    db.session.commit()

    item9 = Item(user_id=1, name="Bat",
                 description="Primis dignissim mattis erat bibendum eu arcu \
        quis cursus", category=category3)
    db.session.add(item9)
    db.session.commit()

    #commit changes
    db.session.commit()

    print "Added Categories, Items, and a User."
from catalog import db
from catalog.models import User, Category, Item
from datetime import datetime
# Create All Tables
print "Creating tables ..."
db.create_all()

# Create First User
print "Creating User ..."
user = User()
user.username = "******"
user.email = "*****@*****.**"
user.gplus_id = '112241070706889739015'
user.created = datetime.utcnow()
user.modified = datetime.utcnow()
db.session.add(user)
db.session.commit()
print "User - Sophie Reddimalla created ID=" + str(user.id)

print "Creating Sample Category Football ..."
category = Category()
category.title = "Football"
category.user_id = user.id
category.created = datetime.utcnow()
category.modified = datetime.utcnow()
db.session.add(category)
db.session.commit()
print "Category - Football created ID=" + str(category.id)

print "Creating Sample Items in Football ..."
item = Item()
Exemple #6
0
 def setUp(self):
     self.app = create_app('application.testing.cfg')
     self.app_context = self.app.app_context()
     self.app_context.push()
     db.create_all()
     Role.insert_roles()
Exemple #7
0
def create_db():
    """Creates the db tables."""
    db.create_all()
Exemple #8
0
def setup():
    with app.app_context():
        db.create_all()
        db.session.commit()
        print("Database tables created")
Exemple #9
0
def main():
    #drop the database tables
    #create the database and the tables
    db.drop_all()
    db.create_all()
    # Create stock, out of the box user
    UserArtV = User(name="Art Vandalay",
                    email="*****@*****.**",
                    picture="/static/costanza.jpg")
    db.session.add(UserArtV)
    db.session.commit()

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

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

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

    category4 = Category(name="Frisbee")
    db.session.add(category4)
    db.session.commit()

    category5 = Category(name="Snowboarding")
    db.session.add(category5)
    db.session.commit()

    category6 = Category(name="Rock Climbing")
    db.session.add(category6)
    db.session.commit()

    category7 = Category(name="Foosball")
    db.session.add(category7)
    db.session.commit()

    category8 = Category(name="Skating")
    db.session.add(category8)
    db.session.commit()

    category9 = Category(name="Hockey")
    db.session.add(category9)
    db.session.commit()

    item1 = Item(user_id=1,
                 name="Stick",
                 description="Interdum odio dignissim in nisi metus\
                 , a elit sit dis cubilia, fringilla praesent pulvinar porta.\
                 Sodales hac bibendum",
                 category=category9)
    db.session.add(item1)
    db.session.commit()

    item2 = Item(
        user_id=1,
        name="Goggles",
        description="Primis dignissim mattis erat bibendum eu arcu quis\
                  cursus",
        category=category5)
    db.session.add(item2)
    db.session.commit()

    item3 = Item(user_id=1,
                 name="Snowboard",
                 description="Curae feugiat netus auctor lacus",
                 category=category5)
    db.session.add(item3)
    db.session.commit()

    item4 = Item(user_id=1,
                 name="Soccer Item 1",
                 description="Nec odio consectetur cum \
                 consequat quam massa habitant placerat, nam tincidunt mi egestas \
                 eu taciti velit dictum aenean, vestibulum inceptos semper \
                 penatibus proin fringilla quisque. Cursus ridiculus facilisis \
                 class erat varius cum consequat, ac at justo mattis magna dui \
                 suscipit interdum, faucibus auctor rhoncus diam parturient a.",
                 category=category1)
    db.session.add(item4)
    db.session.commit()

    item5 = Item(user_id=1,
                 name="Soccer Item 2",
                 description="Fermentum scelerisque \
                 facilisis tortor rhoncus magna maecenas, blandit ligula metus \
                 amet congue fames pulvinar, eget aliquam augue eros per. Vel \
                 etiam dolor ornare aliquet posuere inceptos maecenas nam, varius \
                 eget ad imperdiet mi phasellus turpis nisl libero, urna \
                 tristique aptent ultricies taciti montes parturient.",
                 category=category1)
    db.session.add(item5)
    db.session.commit()

    item6 = Item(user_id=1,
                 name="Soccer Item 3",
                 description="Placerat primis taciti etiam \
                 ut convallis accumsan lorem tortor sapien faucibus cursus, quam \
                 nulla tempor morbi rhoncus suscipit sociis in litora amet enim, \
                 praesent aptent bibendum integer ornare dapibus justo rutrum \
                 aliquet vivamus. Taciti dignissim neque euismod elit maecenas \
                 aptent interdum mollis vel sociosqu donec, nunc gravida eget ad \
                 quisque viverra vitae amet hendrerit.",
                 category=category1)
    db.session.add(item6)
    db.session.commit()

    item7 = Item(user_id=1,
                 name="Soccer Item 4",
                 description="Litora turpis et dignissim \
                 nascetur faucibus taciti vivamus interdum, tempor dapibus lorem \
                 venenatis enim conubia lacus netus hac, dis magnis vel nulla \
                 phasellus bibendum fringilla. Sed torquent taciti accumsan elit \
                 sagittis nulla magnis, sit praesent volutpat nam consectetur \
                 velit, magna sociis id ultrices diam non.",
                 category=category1)
    db.session.add(item7)
    db.session.commit()

    item8 = Item(user_id=1,
                 name="Frisbee",
                 description="Interdum odio dignissim in nisi \
                 metus, a elit sit dis cubilia, fringilla praesent pulvinar \
                 porta. Sodales hac bibendum tincidunt risus mus himenaeos erat \
                 ac, mollis semper integer tempor lacus turpis libero, ridiculus \
                 primis curae aliquet nec rhoncus ante.",
                 category=category4)
    db.session.add(item8)
    db.session.commit()

    item9 = Item(user_id=1,
                 name="Bat",
                 description="Primis dignissim mattis erat bibendum eu arcu \
        quis cursus",
                 category=category3)
    db.session.add(item9)
    db.session.commit()

    #commit changes
    db.session.commit()

    print "Added Categories, Items, and a User."