Esempio n. 1
0
def syncdb():
    from lib.util import find_subclasses
    from model import db, User, Distribution, Category, Page
    
    models = find_subclasses(db.Model)
    for model in models:
        if model.table_exists():
            model.drop_table()
        model.create_table()
        logging.info('created table:%s' % model._meta.db_table)
    
    Distribution.create(name = '免费配送', price = 0)
    Distribution.create(name = '上门自提', price = 0)
    Category.create(name = '积分商品', slug = 'credit', order = 1)
    Category.create(name = '搭配购买', slug = 'acc', order = 2)
    Category.create(name = '慕斯蛋糕', slug = 'mousse', order = 3)
    Category.create(name = '巧克力蛋糕', slug = 'chocolate', order = 4)
    Category.create(name = '乳酪蛋糕', slug = 'cheese', order = 5)
    Category.create(name = '乳脂奶油蛋糕', slug = 'creambutter', order = 6)
    Category.create(name = '冰淇淋蛋糕', slug = 'icecream', order = 7)
    Page.create(name = '吉米的厨房', slug = 'aboutus', content = '')
    Page.create(name = '包装展示', slug = 'bzzs', content = '')
    Page.create(name = '订购说明', slug = 'dgsm', content = '')
    Page.create(name = '如何收货', slug = 'rhsh', content = '')
    Page.create(name = '付款方式', slug = 'fkfs', content = '')
    Page.create(name = '配送范围', slug = 'psfw', content = '')
    User.create(mobile = 'root', password = User.create_password('111111'), group = 9)
    
    logging.info('superuser - username:root password:111111')
Esempio n. 2
0
def init_db():
    from lib.util import find_subclasses
    models = find_subclasses(db.Model)
    for model in models:
        if model.table_exists():
            model.drop_table()
        model.create_table()
Esempio n. 3
0
def syncdb():
    from lib.util import find_subclasses
    from model import db, User, Distribution, Category, Page

    models = find_subclasses(db.Model)
    for model in models:
        if model.table_exists():
            model.drop_table()
        model.create_table()
        logging.info('created table:%s' % model._meta.db_table)

    User.create(mobile='root',
                password=User.create_password('111111'),
                group=9)
    Distribution.create(name='免费配送', price=0)
    Distribution.create(name='上门自提', price=0)
    Category.create(name='积分商品', slug='credit', order=1)
    Category.create(name='搭配购买', slug='acc', order=2)
    Category.create(name='鸡', slug='ji', order=3)
    Category.create(name='鸭', slug='ya', order=4)
    Category.create(name='鹅', slug='e', order=5)
    Category.delete().where(Category.id == 1).execute()
    Category.delete().where(Category.id == 2).execute()
    #Category.create(name = '乳脂奶油蛋糕', slug = 'creambutter', order = 6)
    #Category.create(name = '冰淇淋蛋糕', slug = 'icecream', order = 7)
    Page.create(name='菜市优品', slug='aboutus', content='')
    Page.create(name='包装展示', slug='bzzs', content='')
    Page.create(name='订购说明', slug='dgsm', content='')
    Page.create(name='如何收货', slug='rhsh', content='')
    Page.create(name='付款方式', slug='fkfs', content='')
    Page.create(name='配送范围', slug='psfw', content='')

    logging.info('superuser - username:root password:111111')
Esempio n. 4
0
def syncdb():
    from lib.util import find_subclasses
    from conf.dbconf import db
    from models.user import User  #TODO auto to get model 
    from models.crawler import Proxy_proxy

    models = find_subclasses(db.Model)

    for model in models:
        print model
        if model.table_exists():
            model.drop_table()
        model.create_table()
        logging.info('created table:%s' % model._meta.db_table)