Esempio n. 1
0
def creation_tables():

    database.execute_sql("SET FOREIGN_KEY_CHECKS=0")

    if CategoriesProduct.table_exists():
        CategoriesProduct.drop_table(cascade=True)

    if Category.table_exists():
        Category.drop_table(cascade=True)

    if Product.table_exists():
        Product.drop_table(cascade=True)

    if User.table_exists():
        User.drop_table(cascade=True)

    if Store.table_exists():
        Store.drop_table(cascade=True)

    database.execute_sql("SET FOREIGN_KEY_CHECKS=1")

    User.create_table()
    Store.create_table()
    Product.create_table()
    Category.create_table()
    CategoriesProduct.create_table()
Esempio n. 2
0
def create_tables():
    if Category.table_exists():
        Category.drop_table()

    if Product.table_exists():
        Product.drop_table()

    if Store.table_exists():
        Store.drop_table()

    if User.table_exists():
        User.drop_table()

    User.create_table()
    Store.create_table()
    Product.create_table()
    Category.create_table()