Example #1
0
def code_categories(engine):
    table = sl.get_table(engine, 'representative')
    for cat in sl.distinct(engine, table, 'main_category'):
        if not cat['main_category']: continue
        c=newcats.get(cat['main_category'],cat['main_category'])
        cat['main_category_id'] = CATEGORIES[c]
        sl.upsert(engine, table, cat, ['main_category'])
Example #2
0
def code_subcategories(engine):
    table = sl.get_table(engine, 'representative')
    for cat in sl.distinct(engine, table, 'sub_category'):
        if not cat['sub_category']: continue
        cat['sub_category_id'] = SUBCATEGORIES.get(cat['sub_category'])
        sl.upsert(engine, table, cat, ['sub_category'])
Example #3
0
def remap_subcategories(engine):
    table = sl.get_table(engine, 'representative')
    for cat in sl.distinct(engine, table, 'sub_category'):
        c=newsubcats.get(cat['sub_category'])
        if c:
           sl.update(engine, 'representative', {'sub_category': cat['sub_category']}, {'sub_category': c}, ensure=False)
Example #4
0
def code_categories(engine):
    table = sl.get_table(engine, 'representative')
    for cat in sl.distinct(engine, table, 'main_category'):
        cat['main_category_id'] = CATEGORIES[cat['main_category']]
        sl.upsert(engine, table, cat, ['main_category'])