コード例 #1
0
ファイル: main.py プロジェクト: reialfrl/Database_veterinary
def insert_stores():
    Store.create(user_id=1,
                 name='Veterinaria Ramírez',
                 address='Av. Venezuela 202')
    Store.create(user_id=2,
                 name='Veterinaria Jei',
                 address='Av. 5 de Abril 05-04')
コード例 #2
0
def relationOneToMany():
    #creando usuario
    user = User.create(username='******',
                       password='******',
                       email='*****@*****.**')
    #crenado su tienda se puede ocupar user_id = 1
    store1 = Store.create(name='tienda zoila',
                          address='sin direccion',
                          user=user)
    store2 = Store.create(name='tienda villatoro',
                          address='sin direccion',
                          user=user)

    #viendo la info de la primera tienda
    user = User.get(User.id == 1)
    print(user)

    for store in user.stores:
        print(store)

    store1 = Store.get(Store.id == 1)
    print(store1.user)
コード例 #3
0
def relationOneToOne():

    #creando usuario
    user = User.create(username='******',
                       password='******',
                       email='*****@*****.**')
    #crenado su tienda se puede ocupar user_id = 1
    store = Store.create(name='tienda dayana',
                         address='sin direccion',
                         user=user)

    tienda_facil = Store.get(Store.user_id == 1)
    print(tienda_facil)
    #retorna la relacion con el usuario
    print(tienda_facil.user.username)
コード例 #4
0
def insert_stores():
    Store.create(user_id=1, name='tienda facilita uno', address='Oficinas')
    Store.create(user_id=2, name='tienda facilita dos', address='Oficinas')
コード例 #5
0
def insert_stores():
    Store.create(name='tienda zoila', address='sin direccion', user_id=1)
    Store.create(name='tienda villatoro', address='sin direccion', user_id=2)
コード例 #6
0
def store_add():
   Store.create(name=request.form.get("store_name"))
   return redirect("/store")
コード例 #7
0
def create_store():
   store_name = request.form.get('store_name')
   if Store.create(name = store_name):
      flash("Successfully saved.")
      return redirect(url_for('index'))
コード例 #8
0
ファイル: main.py プロジェクト: rocooper7/6.CodFac
def insert_data(table_name):
    if table_name == 'users':
        user = User.create(username='******',
                           age=30,
                           password='******',
                           email='*****@*****.**')
        user = User.create(username='******',
                           age=35,
                           password='******',
                           email='*****@*****.**')
        user = User.create(username='******',
                           age=60,
                           password='******',
                           email='*****@*****.**')
        user = User.create(username='******',
                           age=68,
                           password='******',
                           email='*****@*****.**')
        user = User.create(username='******',
                           age=23,
                           password='******',
                           email='*****@*****.**')
        user.save()
    elif table_name == 'stores':
        store = Store.create(user_id=1,
                             name='La esquina',
                             address='Fuentes del Molino #10')
        store = Store.create(user_id=1,
                             name='Don Simon',
                             address='Fuentes del Molino #12')
        store = Store.create(user_id=1,
                             name='Carmelita',
                             address='Fuentes del Molino #13')
        store = Store.create(user_id=4,
                             name='Wallis',
                             address='Fuentes del Molino #14')
        store = Store.create(user_id=5,
                             name='Don perse',
                             address='Fuentes del Molino #16')
        store.save()
    elif table_name == 'products':
        product = Product.create(store_id=1,
                                 name='Pan',
                                 description='Pan Integral',
                                 price=5.5,
                                 stock=10)
        product = Product.create(store_id=1,
                                 name='Leche',
                                 description='Baja en grasas',
                                 price=15.5,
                                 stock=24)
        product = Product.create(store_id=1,
                                 name='Jamon',
                                 description='Pavo',
                                 price=45.5,
                                 stock=10)
        product = Product.create(store_id=2,
                                 name='Soda',
                                 description='Dieta',
                                 price=10.5,
                                 stock=10)
        product = Product.create(store_id=2,
                                 name='Fritura',
                                 description='Churros',
                                 price=9.5,
                                 stock=10)
        product = Product.create(store_id=2,
                                 name='Salsa',
                                 description='Habanero',
                                 price=11.5,
                                 stock=10)
        product.save()
    elif table_name == 'categories':
        category = Category.create(name='Liquidos', description='liquidos')
        category = Category.create(name='Embutidos', description='embutidos')
        category = Category.create(name='Snacks', description='snacks')
        category = Category.create(name='Aderezos', description='aderezos')
        category = Category.create(name='Carnes', description='carnes')
        category.save()
    elif table_name == 'product_categories':
        ProductCategory.create(category_id=1, product_id=2)
        ProductCategory.create(category_id=1, product_id=4)
        ProductCategory.create(category_id=2, product_id=3)
        ProductCategory.create(category_id=3, product_id=5)
        ProductCategory.create(category_id=4, product_id=6)
        ProductCategory.create(category_id=5, product_id=3)
コード例 #9
0
def insert_stores():
    Store.create(user_id=1, name='Adidas', addres='Conocida')
    Store.create(user_id=2, name='Nike', addres='Conocida')